SAP AND ABAP TIPS AND FACTS

Monday, June 30, 2008

SAP PLant for a Material

SAP PLant for a Material

To obtain a list of PLANTS for a given MATERIAL you can use the following function module.

SAP Function Module for obtaining list of PLANTS for a given Material

K_VALID_PLANTS_OF_MATERIAL
_____________________________________________________

Here you will get a drop down list of all the PLANTS associated with a MATERIAL

Find the code Below.


REPORT ZEX_VALIDPLANTFORMAT .

Parameter: p_matnr like MARA-MATNR.

Data: int_werks TYPE TABLE OF T001W.

CALL FUNCTION 'K_VALID_PLANTS_OF_MATERIAL'
  EXPORTING
    I_MATNR               = p_matnr
    I_DISPLAY             = ' '
* IMPORTING
*    E_PLANT               =
 TABLES
   I_T001W               = int_werks
 EXCEPTIONS
   NO_VALID_PLANTS       = 1
   OTHERS                = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

See Also:
SAP Locating Plants for a Given Material
SAP get Plant Description For a given Material
SAP PLANT MATERIAL and STORAGE LOCATION
Plant for a Company Code


SAP Company Code for a Plant

SAP Company Code for a Plant

For determining the company code for a plant the following function module can be used.

SAP Function Module for determining company code for a Plant.

HRCA_PLANT_GET_COMPANYCODE
___________________________________________________


Please note that

A PLANT can be assigned to only one COMPANY CODE.
A COMPANY CODE can have several PLANTS assigned to it.

You need to pass the PLANT to the above mentioned Function Module.

Find the code below.

REPORT ZEX_PLANTCOMPANYCODE .


Parameter: p_werk like HRCA_PLANT-PLANT.

Data: d_bukrs like HRCA_COMPANY-COMP_CODE.


CALL FUNCTION 'HRCA_PLANT_GET_COMPANYCODE'
  EXPORTING
    PLANT                       = p_werk
 IMPORTING
   COMPANYCODE                  = d_bukrs
 EXCEPTIONS
   NO_COMPANY_CODE_FOUND        = 1
   PLANT_NOT_FOUND              = 2
   OTHERS                       = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

See Also:
SAP Locating Plants for a Given Material
SAP get Plant Description For a given Material
SAP PLANT MATERIAL and STORAGE LOCATION


SAP Plant Material and Storage Location

SAP Plant Material and Storage Location

For retrieving Storage Location related data for a Material, you can use the following SAP ABAP function module.

SAP Storage Location related data for a Material.

MARD_GENERIC_READ_MATNR_PLANT
___________________________________________________________


The following are the IMPORT parameters:

KZRFB            Indicator: Lock
MATNR           Material
WERKS            Plant
MAXTZ            Maximum number of table lines
____________________________________________________________


The following values are retrieved.

Values from Table
MARD     Storage Location Data for Material
_____________________________________________________________



Code is given below.

REPORT ZEX_STORAGELOC .


Parameter: p_matnr like MARD-MATNR,
           p_werks like MARD-WERKS.


data: int_MARD TYPE TABLE OF MARD.


CALL FUNCTION 'MARD_GENERIC_READ_MATNR_PLANT'
  EXPORTING
*   KZRFB            = ' '
    MATNR            = p_matnr
    WERKS            = p_werks
*   MAXTZ            = 0
  TABLES
    MARD_TAB         = int_MARD
 EXCEPTIONS
   WRONG_CALL       = 1
   NOT_FOUND        = 2
   OTHERS           = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

See Also:
SAP Locating Plants for a Given Material
SAP get Plant Description For a given Material

Friday, June 27, 2008

SAP POP UP TABLE CONTENTS ON THE SCREEN

SAP POP UP TABLE CONTENTS ON THE SCREEN

To POP up table contents on the Screen the following function module can be used.

SAP ABAP function module to POP UP Table contents on the screen.

POPUP_WITH_TABLE_DISPLAY
___________________________________________

While developing a report if you wish to display some internal table contents on the screen it can easily be done with the above mentioned function module. While doing so you can define a hot spot or create a button the screen and pop up the internal table contents.

Find the code below.

The input parameters are as follows

ENDPOS_COL            Make sure that you define a value that will accommodate the complete column length.
ENDPOS_ROW           Put a values to ensure that the rows in the internal table should fit in
STARTPOS_COL        Co-ordinates (X-Axis) of the starting position (Column)of the POP UP Table
STARTPOS_ROW       Co-ordinates (Y-Axis) of the starting position (Row)of the POP UP Table
TITLETEXT                Title to be given

__________________________________________________________________________________________


REPORT ZEX_POPUPTABLE .

Data: d_endpos_col(4) value 25,
      d_ENDPOS_ROW(4) value 5,
      d_startpos_row(4) value 10,
      d_startposcol(4) value 10,
      d_title(100),
      d_choice like SY-TABIX.

Data: begin of int_valtab occurs 0,
      data(100),
      end of int_valtab.

move: 'This is row 1' to int_valtab-data.
append int_valtab.
clear int_valtab.

move: 'This is row 2' to int_valtab-data.
append int_valtab.
clear int_valtab.

move: 'Display Table' to d_title.


 CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
   EXPORTING
     ENDPOS_COL         = d_endpos_col
     ENDPOS_ROW         = d_ENDPOS_ROW
     STARTPOS_COL       = d_startposcol
     STARTPOS_ROW       = d_startpos_row
     TITLETEXT          = d_title
 IMPORTING
    CHOISE             = d_choice
   TABLES
     VALUETAB           = int_valtab
  EXCEPTIONS
    BREAK_OFF          = 1
    OTHERS             = 2
           .
 IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.





Thursday, June 26, 2008

SAP Get Plant Description for a Material

SAP Get Plant Description for a Material

A similar Function Module to the previous post to get the list of all the Plants with their description for a given Material is given below.

SAP ABAP Function Module to extract Plant and Description for a given Material is given below.

CKBA_PLANT_GET_LIST
_______________________________________

Find the code below.

REPORT ZEX_GETPLANT .

Parameter: p_matnr like CKMLMV001-MATNR.

Types:
  BEGIN OF CKBA1_WERKS_STR,
    WERKS LIKE CKMLMV001-WERKS,
    NAME1 LIKE T001W-NAME1,
  END OF CKBA1_WERKS_STR.

Data: CKBA1_WERKS_TBL TYPE CKBA1_WERKS_STR OCCURS 0.



CALL FUNCTION 'CKBA_PLANT_GET_LIST'
  EXPORTING
    I_MATNR           = p_matnr
 IMPORTING
   E_WERKS_TBL       = CKBA1_WERKS_TBL
 EXCEPTIONS
   NO_VALUES         = 1
   OTHERS            = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.



SAP Plants for a given Material

SAP Plants for a given Material

For extracting SAP PLANTS for a given MATERIAL the following function module can be used.

SAP ABAP FUNCTION MODULE for extracting all PLANTS in which the MATERIAL is maintained.

MATERIAL_READ_PLANTS
________________________________________


The import parameters for the above mentioned function module are as follows.

Material Number

All the PLANTS in which the above MATERIAL is maintained are extracted by the above mentioned function Module.

The fileds extracted are as follows.

MANDT       CLIENT
MATNR       Material Number
WERKS        Plant
PSTAT         Maintenance status
______________________________________________________

Find the code below.

REPORT ZEX_PLANTDETAILS .

parameter: p_matnr like mara-matnr.

data: int_plants TYPE TABLE OF MARC_WERK.

CALL FUNCTION 'MATERIAL_READ_PLANTS'
     EXPORTING
          MATNR  = p_matnr
     TABLES
          PLANTS = int_plants.

If sy-subrc = 0.

endif.


Wednesday, June 25, 2008

SAP ABAP Finding and Running Programs

SAP ABAP Finding and Running Programs

Finding and Running programs in SAP is a fairly simple process. Every one know the transaction code SE38 The ABAP Editor. If you have forgotten the program name but you know that it starts with ZSales then you can type the ZSALES* in the transaction SE38 Program Input field and press F4 or the drop down button. You will then be presented with all the programs that have 'ZSALES' as the first 6 characters in their name.

You can also use the Transaction SA38 ABAP EXECUTE PROGRAMS to run programs. Mainly this transaction is used by the Users who do not want to edit/modify or create a new program.

Transaction SA38 does have options to execute the program with variant and in the back ground mode.
_______________________________________________________________

In case you wish to find a program either because you have forgotten the name or you are just looking for a report existing in the system, then you can use any of the Transactions mentioned above. Transaction SE38 has more flexibility.

Let us examine Transaction SE38 for the different options available for finding a program.

Transaction SE38 THE ABAP EDITOR

To find a Program in SAP ABAP goto Utilities >>>>> Find Program (CTRL+SHIFT+F4)

Once you are there you can either enter the Program name or Short Description or development class. All the programs with the same description and development class would be displayed depending on what you had entered.

Finding ABAP Program names based on the following criterion.

Program Author
Last Changed By
Changed On
Program Type
Status
Application
Logical Database
Authorization Group
Only Editor Lock Active
Fixed Point Arithmetic Only

This can be easily achieved by clicking the 'ALL SELECTIONS ' Button (SHIFT+F7)
_______________________________________________________________

Transaction SA38 ABAP EXECUTE PROGRAM

To have more options click on Utilities >>>>>>> Find Program (CTRL+SHIFT+F2)

Here you can search the program based on the following options.

Program
Authorization Group
Application
Status



Tuesday, June 24, 2008

SAP Function Module String Numerical

SAP Function Module String Numerical

For converting a string to a numerical value the follwing Function Module can be used.

SAP ABAP function module to convert string to a numerical value.

IF_CA_MAKE_STRING_NUMERICAL

Find the code below.

REPORT ZEX_STRINGTONUMBER .

Parameter: p_string(20).


data: d_value like CAWAO_S_FIELDS-NUM_VAL.


CALL FUNCTION 'IF_CA_MAKE_STRING_NUMERICAL'
  EXPORTING
    INPUT_STRING        = p_string
 IMPORTING
   VALUE               = d_value
 EXCEPTIONS
   NOT_NUMERICAL       = 1
   OTHERS              = 2
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


Write:/ d_value.


SAP Function Module String Scramble

SAP Function Module String Scramble

In ABAP if you wish to scramble a STRING it can be easy done with the help of the following function module.

SAP FUNCTION MODULE TO SCRAMBLE STRING

DP_SCRAMBLE_STRING

The inputted string is scrambled with some numeric characters.

Note: The LOWER CASE option does not work in this Function Module and you may have to do a work around to make it work.

Find the code below.

REPORT ZEX_STRINGSCR.

Parameter: p_pass(100) LOWER CASE.

data: d_passowrd(100).

d_passowrd = p_pass.

CALL FUNCTION 'DP_SCRAMBLE_STRING'
  CHANGING
    PASSWORD       = d_passowrd
          .

 Write:/ d_passowrd.

Related Links:
Creating Valid Password in SAP
Function Module to Create Passwords in SAP

Monday, June 23, 2008

SAP ABAP Negative Sign Before a Number

SAP ABAP Function Module to place negative Sign Before a Number

In SAP the negative sign by default come after the number. In case if you wish to place the negative sign before the number the following function module should be used.

SAP ABAP Function Module to place the sign before a number.

CLOI_PUT_SIGN_IN_FRONT

The above mentioned function module has the following parameters.

VALUE

Note: This is a changing parameter and accepts the value with Data Type Character.

Find the code below.

REPORT ZEX_SIGN .

Parameter: p_num1 type i,
           p_num2 type i.

Data: d_sum type i,
      d_value(10).

d_sum = p_num1 + p_num2.
d_value = d_sum.

Write: d_sum.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
  CHANGING
    VALUE         = d_value
          .
SKIP.
write:/ d_value RIGHT-JUSTIFIED.



SAP Function Module Import Clipboard

SAP Function Module Import Clipboard

If you wish to import the contents of the clipboard into SAP, then you can use the function module given below.

SAP ABAP function module to import the windows clipboard contents

CLPB_IMPORT

The above mentioned Function Module grabs the contents of the windows clipboard into an internal table. Once the contents are in the internal table they can be processed as desired.

Find the code below.

REPORT ZEX_CLIPBOARDIMP .

types: ty_tab(200) type c.
Data: wa_tab type ty_tab,
      int_tab type table of ty_tab.



CALL FUNCTION 'CLPB_IMPORT'
     TABLES
          DATA_TAB   = int_tab
     EXCEPTIONS
          CLPB_ERROR = 1
          OTHERS     = 2.

IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.



SAP ABAP Copy to ClipBoard Function Module

SAP ABAP Copy to ClipBoard Function Module

If you wish to copy the contents of the internal table to the Windows clipboard, you can do so by using the following function module.


SAP ABAP Function Module Copy to Clipboard
CLPB_EXPORT

If you use this function module, then the contents of the internal table can be copied to the Clipboard of the Presentation Server. Once the contents are copied to the clipboard they can be pasted into any windows application.


Find the code below.

REPORT ZEX_CLIPBOARDEXP .

types: ty_tab(200) type c.
Data: wa_tab type ty_tab,
      int_tab type table of ty_tab.

Move: 'This is line 1 again' to wa_tab.
append wa_tab to int_tab.
clear wa_tab.

Move: 'This is line 2 again' to wa_tab.
append wa_tab to int_tab.
clear wa_tab.

CALL FUNCTION 'CLPB_EXPORT'
     TABLES
          DATA_TAB   = int_tab
     EXCEPTIONS
          CLPB_ERROR = 1
          OTHERS     = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


Sunday, June 22, 2008

SAP Tool Based Reports

SAP Tool Based Reports

One of the Tool used to generate reports in SAP is given below.

  • Report Painter and Report Writer
SAP Report Writer and Report Painter:

This tool can be accessed as follows.

SAP Menu >>>> Information Systems >>>> Ad Hoc Reports >>>> Report Painter


Under Report Painter you have the following Options

Report (GRR1 Create, GRR2 Change, GRR3, Display, GR34 Delete)
Model  (GRR4 Create, GRR5 Change, GRR6 Display)
Utilities
  Catalog
  Transport
Report Writer
  Set
  Variable
  Key Figures
  Standard Layout
  Library
  Report
  Report Group
  
Note: Instead of using ABAP code to write a report in FI and CO, Transaction MC27 is used by a lot of consultants to build a report by using Report Painter/ Report Writer library.  Transaction  GRCT has many advantages over MC27 in most cases, and eliminates the need to use transaction MC27.

Friday, June 20, 2008

SAP Goods Movement

SAP Goods Movement

In SAP goods are moved in different locations. There are transactions that are responsible for carrying out the Goods Movement.  For carrying out goods movement the following need to be understood. Goods Receipt, Goods Issue, Stock Transfer, Transfer Posting.

SAP Goods Receipt:

When goods are received from a vendor or from production and a posting is carried out in SAP, then it is known as a  Goods Receipt (GR). Once a Goods Receipt is performed the Ware House Stock is increased.

Goods Issue:

Goods going out are termed as goods Issue. Basically it can be of the following type.

  • Material Issue
  • Material Withdrawal
  • Material Consumption
  • Shipment of Goods
Once the posting is carried out in SAP , Goods Issue results in Reduction of Stock.

Stock Transfer:

The movement of goods internally from one place to another is termed as stock transfer. This can be between Storage Location to Storage Location, Warehouse to Warehouse or between Bins, between same plants or between different plant.

Transfer Posting:

Some examples of Transfer Postings are as follows.

Material to Material, Release from Quality Inspection Stock, Transfer of consignment in companies own stock. A transfer posting may or may not carry out a physical movement of goods.



SAP Production Planning and Controlling Standard Reports

No Report Selection Screen Transaction Description Area
1 Order Progress Report

Plnt                          
Sales order                   
Sales order item              
Project                       
WBS element                   
Material                      
Production/process order, netwo
Plnd order 
Overall prof

CO46 This is a very good report which gives the status of the orders in progress.  
2 Production Order Information System

Production order           
Material                   
Production plant           
Planning plant             
Order type                 
MRP controller             
Production scheduler       
Sold-to party              
Sales order                
Sales order item           
WBS element                
Sequence number            
Priority                   
Selection profile status   
Sys. status 
Work center         
Plant               
Selection profile   
Sys. status
Component            
Plant                
Storage location     
Selection profile    
Sys. status    
Basic start date          
Basic finish date         
Scheduled start date      
Scheduled finish date     
Scheduled release date    
Actual start date         
Actual finish date        
Actual release date       

COOIS This report gives complete information on Production Orders. Production Planning
3 Production Order Cost Analysis Order
Cumulated    
Limited      
KKBC_ORD This report basically gives a report on Target Cost against the Actual Cost Production Planning
4 Planning Report Cost Center KSBL

This report can be used to view cost center plan

Controlling
5 Profitability Report Operating Concern
Report
Variant
KE30

This report can give you profitability at the sales order level. However it is necessary to implement PA module

Controlling

Thursday, June 19, 2008

SAP MRP List Function Module

SAP MRP List Function Module

To get a MRP list similar to SAP Transaction MD05 you can use the following Function Module.

SAP ABAP Function Module to get MRP list

MD_MRP_LIST_API

The above mentioned Function Module gives MRP List output. For more details on the outputted list please check the following

OutPut Parameters

Structure
MDPS                              Item in MRP document
MDEZ                              Individual lines of the MRP elements
MDSU                             Total lines for MRP elements

Input Parameters

PLSCN                           Planning scenario in long-term planning
MATNR                         Material Number
WERKS                          Plant
BERID                           MRP area
AFIBZ                            Name of display filter
LIFNR                            Vendor Number

Related Tables

MDKP                             Header Data for MRP Document
MDTB                             MRP table
MDTC                             Aggregated MRP table items
T457T                             Description of MRP elements

Related Transaction Code MD05
_____________________________________________________

Please find the code below.

REPORT ZEX_MRPLIST .


Parameter: p_matnr like MARC-MATNR,
           p_werks like MARC-WERKS.


Data: st_MT61D like MT61D,
      st_MDKP  like MDKP,
      int_MDPS TYPE TABLE OF MDPS,
      int_MDEZ TYPE TABLE OF MDEZ,
      int_MDSU TYPE TABLE OF MDSU.


CALL FUNCTION 'MD_MRP_LIST_API'
  EXPORTING
*   PLSCN                          =
    MATNR                          = p_matnr
    WERKS                          = p_werks
*   BERID                          =
*   AFIBZ                          =
*   SINFG                          = 'X'
*   LIFNR                          =
*   AFHOR                          =
*   DTNUM                          =
*   INPER                          =
*   DISPLAY_LIST_MDPSX             =
*   DISPLAY_LIST_MDEZX             =
*   DISPLAY_LIST_MDSUX             =
 IMPORTING
   E_MT61D                        = st_MT61D
   E_MDKP                         = st_MDKP
 TABLES
   MDPSX                          = int_MDPS
   MDEZX                          = int_MDEZ
   MDSUX                          = int_MDSU
 EXCEPTIONS
  MRP_LIST_NOT_FOUND             = 1
   MATERIAL_PLANT_NOT_FOUND       = 2
   ERROR                          = 3
   OTHERS                         = 4
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

SAP Stocks/Requirements List Function Module

SAP Stocks/Requirements List Function Module

To get a list of Stocks/Requirements in SAP, you can use the Function Module given below.

SAP ABAP Function Module to get Stocks/Requirements List.

MD_STOCK_REQUIREMENTS_LIST_API
______________________________________________________


The above mentioned SAP Function Module extracts data that is similar to transaction MD04 (Stocks/Requirement List).

Note: This function module is an RFC (Remote-Enabled Module) this makes it accessible from non-sap systems as well

Related Logical Database MSM

For Logical Database See Also:

Logical DataBase Programs
Logical Database Structure
__________________________________________________________________________________________________________

The Function Module
MD_STOCK_REQUIREMENTS_LIST_API takes the following inputs

PLSCN        Planning scenario in long-term planning
MATNR       Material
WERKS        Plant
BERID         MRP Area
ERGBZ        Selection rule
AFIBZ         Name of display filter
INPER         Internal period indicator
DISPLAY_LIST_MDPSX
DISPLAY_LIST_MDEZX
DISPLAY_LIST_MDSUX
____________________________________________________________________________________________________________

The following Parameters are exported.

Material number, Plant, Deletion Flag, Material description, Material type, Material group, Base unit of measure, Plant-Specific Material Status, MRP type, Procurement Type, Special procurement type, Mixed MRP indicator, Low-level code, Dependent requirements ind. for individual and coll. reqmts, Indicator for Requirements Grouping, MRP controller, Purchasing group, Indicator: MRP controller is buyer (deactivated), In-house production time, Processing time, Setup and teardown time, Interoperation time, Base quantity, Scheduling Margin Key for Floats, Planned delivery time in days, Goods receipt processing time in days, Total replenishment lead time (in workdays), Indicator: automatic fixing of planned orders, Lot size (materials planning), Fixed lot size, Minimum lot size, Maximum lot size, Rounding value for purchase order quantity, Maximum stock level, Assembly scrap in percent, Safety stock, Reorder point, Ordering costs, Storage costs indicator, Forecast indicator, Period indicator, Splitting Indicator, Discontinuation indicator, Effective-Out Date,, Follow-up material, Method for Selecting Alternative Bills of Material, Valuation class, Price control indicator, Moving average price/periodic unit price, Standard price, Price unit, Stock in transfer (plant to plant)

For more Details of the fields see the following

Structure
MT61D
MDPS
MDEZ
MDSU
Transparent Table
MDKP
______________________________________________________________________

See the functional code below.

REPORT ZEX_STOCKREPORT .

Parameter: p_matnr like MARC-MATNR,
           p_werks like MARC-WERKS.


DATA: int_mdpsx  TYPE TABLE OF mdps,
      int_mdezx  TYPE TABLE OF mdez,
      int_mdsux  TYPE TABLE OF mdsu,
      int_mdinx  TYPE TABLE OF mdin.

DATA: wa_mt61d TYPE mt61d,
      wa_mdezx TYPE mdez.

* Initial screen
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
  EXPORTING
    matnr   = p_matnr
    werks   = p_werks
  IMPORTING
    e_mt61d = wa_mt61d
  TABLES
    mdpsx   = int_mdpsx
    mdezx   = int_mdezx
    mdsux   = int_mdsux
  EXCEPTIONS
    OTHERS  = 1.


    if sy-subrc = 0.

    endif.


See Also:
SAP Availability Check BAPI/Function Module

Wednesday, June 18, 2008

SAP Availability Check BAPI/Function Module

SAP Availability Check BAPI/Function Module

If you need to check the availability of a Material using a program, then you can make use of the following BAPI.

SAP Availability check BAPI
BAPI_MATERIAL_AVAILABILITY
__________________________________

This BAPI returns the Available quantity.

The code given below shows how to call this BAPI. The import parameters of this BAPI are

Material
Plant
Unit
________________________


REPORT ZEX_AVAILIBILITYCHK .

Parameter: p_matnr like BAPIMATVP-MATNR,
           p_werks like BAPIMATVP-WERKS,
           p_unit  like BAPIADMM-UNIT.

*Data: int_wmdvsx like BAPIWMDVS occurs 0 with header line,
*      int_wmdvex like BAPIWMDVE occurs 0 with header line.

Data: int_wmdvsx  type table of bapiwmdvs with header line,
      int_wmdvex  type table of bapiwmdve with header line,
      d_WKBST like BAPICM61V-WKBST.



           CALL FUNCTION 'BAPI_MATERIAL_AVAILABILITY'
             EXPORTING
               PLANT                    = p_werks
               MATERIAL                 = p_matnr
               UNIT                     = p_unit
*              CHECK_RULE               =
*              STGE_LOC                 =
*              BATCH                    =
*              CUSTOMER                 =
*              DOC_NUMBER               =
*              ITM_NUMBER               =
*              WBS_ELEM                 =
*              STOCK_IND                =
*              DEC_FOR_ROUNDING         =
*              DEC_FOR_ROUNDING_X       =
*              READ_ATP_LOCK            =
*              READ_ATP_LOCK_X          =
            IMPORTING
*              ENDLEADTME               =
               AV_QTY_PLT               = d_WKBST
*              DIALOGFLAG               =
*              RETURN                   =
             TABLES
               WMDVSX                   = int_wmdvsx
               WMDVEX                   = int_wmdvex
                     .


Write:/ d_WKBST.

 If sy-subrc = 0.

 endif.


Creating a Valid Password in SAP

Creating a Valid Password in SAP

Find below some useful tips for creating a new Password in SAP.

  • Length of the SAP Password has to be in the range of 3 to 8 Characters
  • If you are changing the password, then the new password should not be a replica of any of the last 5 passwords
  • Password should not be the reserved words pass or init
  • SAP Password cannot be a blank space
  • The first 3 characters of a Password cannot be the same for example nnnewp
  • As mentioned in the first point a password cannot be less then 3 characters eg. fl
  • Password cannot contain an exclamation mark !file
  • SAP Password cannot contain a question mark eg. ?mypass
  • The password can be any combination of alphanumeric characters including a to z, 0 to 9 and punctuation marks
When ever you are logging on to the SAP system for the first time, you need to enter a new password. It is always a good practice to change the password every month. Many companies have a Password Policy and you need to follow these policies strictly.
__________________________________________________________________

See Also: Function Module to Generate SAP Password


Tuesday, June 17, 2008

SAP R/3 Bookmarking Websites

SAP R/3 Bookmarking Websites

In the WEB 2.0 world each and every one of us is connected to the Web from work and/or from home. SAP R/3 has a way of Bookmarking your favorite websites. All the SAP related websites/URLs can be added to the favorite menu in SAP, this makes it easier and convenient for the user to visit the websites of their choice.

To add your favorite URL/Website to the SAP Menu please follow the steps given below.

In the SAP main Screen Right Click on the Favorite's Menu.

The following option will be available.

Open Folder
Delete all Favorite
Insert Folder
Insert Transaction
Add Other Objects

To add a Web Address/URL/Website click on Insert Folder. You will be presented with a Dialog Box with the following fields.

  • Folder Name
Enter the Desired Folder Name. If you wish to enter the name of your Favorite SAP Website ABAPLOVERS.BLOGSPOT.COM then create a FOlder with the name ABAPLOVERS.

Once this folder is created right click on ABAPLOVERS. The following options will be available.

Open Folder
Change Favorite
Delete Favorite
Insert Folder
Insert Transaction
Add Other Objects

Select Add Other Objects, then the following options will be available.

Web Address or File
Drag-and-Relate Component
Knowledge Warehouse
SAPScript (text defined with SE16)

Select Web Address or File. In the resulting Dialog Box enter the following.

Text                                                  ABAPLOVERS Tutorials on ABAP
Web Address or File                         http://www.abaplovers.blogspot.com

Click on ok

Similarly you can Add any other transaction or a website of your choice in the Favorite's menu.















ABAP TIPS

PREVIOUS                  NEXT                    RANDOM

 ABAP TIPS


Since your web browser does not support JavaScript, here is a non-JavaScript version of the image slideshow:

 ABAP TIPS
Always specify your conditions in the Where-clause instead of checking them yourself with check statements. The database system can then use an index (if possible) and the network load is considerably less.


 ABAP TIPS
For all frequently used Select statements, try to use an index. You always use an index if you specify (a generic part of) the index fields concatenated with logical Ands in the Select statement's Where clause. Note that complex Where clauses are poison for the statement optimizer in any database system.


 ABAP TIPS
If there exists at least one row of a database table or view with a certain condition, use the Select Single statement instead of a Select-Endselect-loop. Select Single requires one communication with the database system, whereas Select-Endselect needs two.


 ABAP TIPS
It is always faster to use the Into Table version of a Select statement than to use Append statements.


 ABAP TIPS
To read data from several logically connected tables use a join instead of nested Select statements. Network load is considerably less.


 ABAP TIPS
If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself. Network load is considerably less.


 ABAP TIPS
If you process your data only once, use a Select-Endselect-loop instead of collecting data in an internal table with Select Into Table. Internal table handling takes up much more space.


 ABAP TIPS
Use a select list or a view instead of Select * , if you are only interested in specific columns of the table. Network load is considerably less.


 ABAP TIPS
For all frequently used, read-only tables, try to use SAP buffering. Network load is considerably less.


 ABAP TIPS
Whenever possible, use array operations instead of single-row operations to modify your database tables. Frequent communication between the application program and database system produces considerable overhead.


 ABAP TIPS
Whenever possible, use column updates instead of single-row updates to update your database tables. Network load is considerably less.


 ABAP TIPS
Instead of using nested Select loops or FOR ALL ENTRIES it is often possible to use subqueries. Network load is considerably less.


 ABAP TIPS
Use the special operators CO, CA, CS, instead of programming the operations yourself. If ABAP/4 statements are executed per character on long strings, CPU consumption can rise substantially.


 ABAP TIPS
Some function modules for string manipulation have become obsolete and should be replaced by ABAP/4 statements or functions: STRING_CONCATENATE... -> CONCATENATE, STRING_SPLIT... -> SPLIT, STRING_LENGTH -> strlen(), STRING_CENTER -> WRITE...TO...CENTERED, STRING_MOVE_RIGHT -> WRITE...TO...RIGHT-JUSTIFIED


 ABAP TIPS
Use the CONCATENATE statement instead of programming a string concatenation of your own.


 ABAP TIPS
If you want to delete the leading spaces in a string, use the ABAP/4 statement SHIFT...LEFT DELETING LEADING... .Other constructions (with CN and SHIFT...BY SY-FDPOS PLACES, with CONDENSE if possible, with CN and ASSIGN CLA+SY-FDPOS(LEN) ...) are not as fast. In any case, avoid using SHIFT inside a WHILE-loop!


 ABAP TIPS
Use the SPLIT statement instead of programming a string split yourself.


 ABAP TIPS
Use the strlen( ) function to restrict the DO loop to the relevant part of the field, e.g. when determinating a check-sum.


 ABAP TIPS
Use "CLEAR f WITH val" whenever you want to initialize a field with a value different from the field's type-specific initial value.


 ABAP TIPS
Try to keep the table ordered and use binary search or used a table of type SORTED TABLE. If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).


 ABAP TIPS
A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime. However, for large tables the costs are dominated by number of comparison needed to locate the entry.


 ABAP TIPS
If you need to access an internal table with different keys repeatedly, keep your own secondary indices.With a secondary index, you can replace a linear search with a binary search plus an index access.


 ABAP TIPS
LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally. As with any logical expressions, the performance is better if the operands of a comparison share a common type. The performance can be further enhanced if LOOP ... WHERE is combined with FROM i1 and/or TO i2, if possible.


Always use Pretty Printer and Extended Program Check before releasing the code. Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.

Ole Automation Part1
Ole Automation Part 2
Processing Blocks in ABAP
Simple ABAP Report
ALV Grid - Changing Colors
ALV Report Example
Creating Variants For ABAP Reports
Recording BDC using Transaction
Sales Document Flow in ABAP
User Exits in SAP SD
SAP ABAP Naming Standards
SAP SD Tables
SAP ABAP Data Dictionary Tables
MM Important Transaction Codes in SAP
Passing g Data From One ABAP Program to Another
ABAP Compute Add Collect and Append
SAP ABAP Determining Attributes of Data
SAP ABAP Editor Icons
BAPI for Displaying Material Data
BAPI to get customer bank details
EDI Outbound Process
SAP EDI Process Overview
Function Module for Vendor Bank details
SAP IDOC
Creating a Valid Password in SAP
SAP BADIs Introduction
SAP ABAP MACROS
POP UP function Module to Confirm and Save Data
Select Options
BAPI for availability check
String to Numerical
SAP Goods Movement Process
Getting a List of Plants for a Material
SAP R3 Clients Concept
ABAP Adobe Forms
Authorization Object Tables
SAP Industry Specific Solutions

Sap Scripts and SmartForms Bar Codes
Standard Reports and Sap Scripts
Important Standard Reports in SAP
Abap Tricks and Tips
Bapi Sales Order
BAPI Purchase Order
Creating Function Modules in SAP
Creating Tables in SAP
Finding User Exits in SAP
Function Module Create Text and Read Text
Important Transaction Codes in SAP
ABAP Function Module for Submitting a Program
ABAP Game Tic Tac Toe
ABAP Internal Table To Excel Sheet
ABAP Function Module to create Directory
Different Types of Menus in SAP
Function Modules in SAP to check Loged in Users
ABAP Function Module for Adding Days to Dates
Call a Transaction From a Remote System
SAP MM simple Procurement Cycle
BAPI Material EDIT
Finding Decimal Places in Currency
Getting negative sign before a number in ABAP
Program Editor Lock Unlock
Restricting Select Options
List of BAPIs in the system
SAP Function Module Scramble a String
LSMW
POP up table contents on the screen
SAP R3 Bookmarking Websites
Stock Requirements List Function Module
Retail Transaction Codes
ABAP Debugger Break Points
ABAP Debugger WatchPoints
Drill Down Reports Concept
Creating a HOT SPOT
Interactive Programs and Hide Technique
String Concatenate
Get Week of the Year
SAP ABAP to Add Days to a Date
Add Months to a Date
Get Month in the Year
Display Clock

ABAP Code For Progress BAR
ABAP Function Module For Caluclator
ABAP Function Module For Calender
Displaying Messages in ABAP
Function Module Pop Up To Confirm
Conversion Routines in SAP
SAP ABAP Authorization
SAP ABAP Module Pool Tutorial
SAP ABAP RFC

Finding Path to SAP Transaction in Menu
SAP Purchasing Documents
SAP and ABAP Shortcuts
Logical Databases
Advantages of Logical Databases
Copy to Clipboard
BAPI Create Material
Finding and Running Programs in ABAP
Program Syntax Check and Extended Syntax Check
Select Options upper lower case
BAPI Sales Order Simulate
Get PLANT and Description for a Material
MRP List Function Module
Production Planning and Controlling
Applications in SAP R3
Tool Based Reports
Important Transaction Codes in SAP
SAP Stock per Bin
Pop Up a Calender
Module to Read a File
Module to Reverse A String
Run an Executable Program with Parameters
Program for POP up Screen
Printing Selection Parameters for a Report
Uploading and DownLoading a Report
SAP ABAP Version Management
SAP ABAP Short Cuts
List of Important System Variables

ABAP MACROS
ABAP Calling a File Selector
Some Important Function Modules
ABAP String Operations

ABAP Function Module to Check Validity of Date
Transfer Internal Table Contents to a File

SAP ABAP Program Types
BAPI to Read Customer Data
Checking Validity of Date
Download to Application Server
ABAP Debugger Breakpoint and Watchpoint
BAPI to get Company Code Details
Creating Material Using BAPI part 2
Generating a Valid Password
Logical Databases Structure
Making Fields OBligatory in Selection Screen
ABAP Views
Getting a Company Code for a Plant
Importing contents of Clipboard in SAP
Getting a Plant for a Material
Plant Material and Storage Location
SAP Production Planning Standard Reports
NetWeaver Components
Supported Databases and Operating Systems