Saturday, May 31, 2008

SAP BAPI for displaying Material Data

SAP BAPI for displaying Material Data

If you wish to display Material data related to Material General Data, Material Plant Data and Material Valuation Data then you can use the following BAPI. This BAPI displays the above mentioned data for a Material.

BAPI/Function Module to display Material Data / Display Material Data BAPI/Function Module

BAPI_MATERIAL_GET_DETAIL

This BAPI has 4 input parameters

Material  (Mandatory)
Plant
Valuation Area
Valuation Type

Please find the code below.

REPORT ZEX_GETMATDET .

Parameters: p_matnr like BAPIMATDET-MATERIAL,
            p_werks like BAPIMATALL-PLANT,
            p_valara like BAPIMATALL-VAL_AREA,
            p_valtyp like BAPIMATALL-VAL_TYPE.


Data: st_matgendata like BAPIMATDOA,
      st_matplantdat like BAPIMATDOC,
      st_matvaldat like BAPIMATDOBEW,
      d_return like BAPIRETURN.


CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
  EXPORTING
   MATERIAL                   = p_matnr
   PLANT                       = p_werks
   VALUATIONAREA               = p_valara
   VALUATIONTYPE               = p_valtyp
 IMPORTING
   MATERIAL_GENERAL_DATA       = st_matgendata
   RETURN                      = d_return
   MATERIALPLANTDATA           = st_matplantdat
   MATERIALVALUATIONDATA       = st_matvaldat .

   If sy-subrc = 0.

   endif.


Important Transactions related to Material Management

Create General

MM01 Immediate
MM11 Schedule
____________________________________________

Create Special

MMR1 Raw Material
MMB1 Semi finished  Product
MMF1 Finished Product
MMI1 Operating Supplies
MMH1 Trading Goods
MMU1 Non Valuated Material
MMN1 Non Stock Material
MMV1 Packaging
MMl1 Empties
MMS1 Services
MMk1 Configurable Material
MMP1 Maintenance Assembly
MMW1 Competitor Product
MMG1 Returnable Packaging
______________________________________________

Change

MM02 Immediately
MM12 Schedule
MM13 Active
______________________________________________

Display

MMO3 Current
MM19 Display at Key Date




 

 



Finding Path to SAP Transaction in the Menu

Finding Path to SAP Transaction in  Menu

You may be knowing the SAP transaction, and would like to trace the path to this transaction in the SAP menu. To do this SAP has provided a way. There is a transaction called SEARCH_SAP_MENU.

With the help of this transaction you can easily search the path to a particular transaction. For example if you wish to search the path to the transaction XD01 (Create Customer Centrally) then you can execute the transaction
SEARCH_SAP_MENU and hit enter. You will see the following. You can then choose the one that has the shortest path.

Finding SAP Transaction in the Menu
SEARCH_SAP_MENU

Node               Transaction code    Text                                  
                                                                             
Nodes              XD01                Full                                  
Preceding node                         Create                                
Preceding node                         Customer                              
Preceding node                         Business partner                      
Preceding node                         Customer                              
Preceding node                         Environment                           
Preceding node                         Customer Rebate Arrangements          
Preceding node                         Subsequent Settlement                 
Preceding node                         Master Data                           
Preceding node                         Purchasing                            
Preceding node                         Materials Management                  
Preceding node                         Logistics                             
                                                                             
Nodes              XD01                Create                                
Preceding node                         Customer                              
Preceding node                         Master Data                           
Preceding node                         Import / Export                       
Preceding node                         General Foreign Trade Processing      
Preceding node                         Foreign Trade/Customs                 
Preceding node                         Materials Management                  
Preceding node                         Logistics                             
                                                                             
Nodes              XD01                Central                               
Preceding node                         Create                                
Preceding node                         Customer Master                       
Preceding node                         Environment                           
Preceding node                         General Foreign Trade Processing      
Preceding node                         Foreign Trade/Customs                 
Preceding node                         Materials Management                  
Preceding node                         Logistics                             

Nodes              XD01                Complete                                    
Preceding node                         Create                                      
Preceding node                         Customer                                    
Preceding node                         Business partners                           
Preceding node                         Master Data                                 
Preceding node                         Sales and Distribution                      
Preceding node                         Logistics                                   
                                                                                   
Nodes              XD01                Create                                      
Preceding node                         Customer                                    
Preceding node                         Master Data                                 
Preceding node                         Import / Export                             
Preceding node                         General Foreign Trade Processing            
Preceding node                         Foreign Trade/Customs                       
Preceding node                         Sales and Distribution                      
Preceding node                         Logistics                                   
                                                                                   
Nodes              XD01                Central                                     
Preceding node                         Create                                      
Preceding node                         Customer Master                             
Preceding node                         Environment                                 
Preceding node                         General Foreign Trade Processing            
Preceding node                         Foreign Trade/Customs                       
Preceding node                         Sales and Distribution                      
Preceding node                         Logistics                                   
                                                                                   
Nodes              XD01                Total                                       
Preceding node                         Create                                      
Preceding node                         Customer                                    
Preceding node                         Partner                                     
Preceding node                         Master Data                                 
Preceding node                         Logistics Execution                         
Preceding node                         Logistics                                   

                                                                         
Nodes              XD01                Complete                          
Preceding node                         Create                            
Preceding node                         Customer                          
Preceding node                         Business partners                 
Preceding node                         Master Data                       
Preceding node                         Sales and Distribution            
Preceding node                         Environment                       
Preceding node                         Service Processing                
Preceding node                         Customer Service                  
Preceding node                         Logistics                         
                                                                         
Nodes              XD01                Complete                          
Preceding node                         Create                            
Preceding node                         Customer                          
Preceding node                         Business partners                 
Preceding node                         Master Data                       
Preceding node                         Sales and Distribution            
Preceding node                         Environment                       
Preceding node                         Service Agreements                
Preceding node                         Customer Service                  
Preceding node                         Logistics                         
                                                                         
Nodes              XD01                Full                              
Preceding node                         Create                            
Preceding node                         Customer                          
Preceding node                         Business partner                  
Preceding node                         Customer                          
Preceding node                         Master Data                       
Preceding node                         Environment                       
Preceding node                         Agency Business                   
Preceding node                         Logistics  

                    




SAP function Module to get vendor Bank Details

SAP function Module to get vendor Bank Details

If you wish to extract the bank details of a particular vendor then you can use the following BAPI.

BAPI/Function Module  for vendor bank details extraction

BAPI_VENDOR_GETDETAIL


Please find below the code to extract vendor Bank Details.

REPORT ZEX_CUSTOMERBANK .


Parameters: p_kunnr like BAPICUSTOMER_ID-CUSTOMER,
            p_bukrs like BAPICUSTOMER_ID-COMP_CODE.

Data: ty_knbk type knbk,
      ty_custadd type BAPICUSTOMER_04,
      ty_custgendet type BAPICUSTOMER_KNA1,
      ty_custcompdet type BAPICUSTOMER_05,
      d_ret         like BAPIRET1.

Data: wa_custadd like ty_custadd,
      wa_custgendet like ty_custgendet,
      wa_custcompdet like ty_custcompdet.

Data: int_knbk like ty_knbk occurs 0.

CALL FUNCTION 'BAPI_CUSTOMER_GETDETAIL2'
  EXPORTING
    CUSTOMERNO                  = p_kunnr
   COMPANYCODE                  = p_bukrs
 IMPORTING
   CUSTOMERADDRESS              = wa_custadd
   CUSTOMERGENERALDETAIL        = wa_custgendet
   CUSTOMERCOMPANYDETAIL        = wa_custcompdet
   RETURN                       = d_ret
 TABLES
   CUSTOMERBANKDETAIL           = int_knbk      .

   if sy-subrc = 0.

   Endif.



Related Topics:

Read Vendor



Friday, May 30, 2008

SAP ABAP Function Module To Read Vendors

SAP ABAP Function Module To Read Vendors

If you wish to extract Vendor Master: General data and Vendor Master: Company data then you can use the following function module.

ABAP Function Module to Read vendor Master
VENDOR_READ

The following program show the parameters that need to be passed to the function module. Basically you need to pass the Vendor Number and the Company Code.

REPORT ZEX_VENDORREAD .

Parameters: p_lifnr like LFA1-LIFNR,
            p_bukrs like LFB1-BUKRS.

Data: st_lfa1 like LFA1,
      st_lfb1 like LFB1.

CALL FUNCTION 'VENDOR_READ'
  EXPORTING
    I_BUKRS         = p_bukrs
    I_LIFNR         = p_lifnr
 IMPORTING
   E_LFA1          = st_lfa1
   E_LFB1          = st_lfb1
 EXCEPTIONS
   NOT_FOUND       = 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.

Find below a list of Vendor Master related tables:

LFA1 - Vendor Master: General data
LFB1 - Vendor Master: Company data
LFM1 - Vendor Master: Purchasing Data (Purchasing organization)
LFM2 - Vendor Master: Purchasing Data (Plant, Vendor sub-range)
LFBK - Vendor Master Bank Details

Note: For more vendor Master tables enter LF* in SE11 ad press F4

Vendor Related important Transaction Codes.

Vendor Purchasing

Create - MK01
Change - MK02(Current)
Change - MK12 (Planned)
Display - MK03 (Current)
Display - MK19 (Per Key Date)
Changes - MK04 Vendor Account Changes
Changes - MK14 Planned Changes
Block - MK05
Flag for Deletion - MK06
Evaluation in Background - ME6G

Vendor Central

Create - XK01
Change - XK02
Display - XK03
Changes - Xk04
Block - XK05
Flag for Deletion -  XK06
Account Group Change - XK07






Thursday, May 29, 2008

SAP EDI OutBound Process

SAP EDI OutBound Process

The EDI Out Bound Process comprises of the following.

  • Selection Program
  • Message Control
  • The Port Definition
  • The RFC Destination
  • The Partner Profile
The important SAP IDOC (EDI) Transactions are as follows.

WEDI is the main transaction for IDOCs. This has a sub-menu that lists all other transactions.

I will list the transactions related to the above mentioned topics.

1) Message Control:

The transaction NACE will list all the applications that use Message Control. For example

V1 Sales
V2 Shipping

from the NACE transaction you can view the following for the various applications

Condition Records
Procedures
OutPut Types
Access Sequence

Message control is responsible to process various outputs fro example EDI, FAX, Printing and Mail.

2) Port Definition:

Transaction WE21

Port definition is used to determine the following

  • Path and name of the IDOC file at the operating system level
  • EDI subsystem subprogram
  • RFC Destination
3) RFC Destination:

Transaction SM59

RFC destination is basically the Remote Function Call Destination. RFC destination is used to define access to the EDI subsystem.

Basically it is used to define the following types of connections
                                    
  • R/2 connections                     
  • R/3 connections                     
  • Internal connections                
  • Logical destinations                
  • TCP/IP connections                  
  • Connections via ABAP/4 driver    

4) Partner Profile 

Transaction WE20

Basically partner profiles are used to define the following


  • IDOC Type
  • Partner Number
  • Port
  • Message Type
  • Process Code
  • Mode of communication with Sub-System
  • Person to be notified

For establishing EDI process with the business Partners (ex Vendors, Customers) A partner Profile is created for each partner.

                                    
                                    

SAP BAPI To Get Customer Bank Details

SAP BAPI To Get Customer Bank Details

In case you wish to extract the Bank Data for a particular customer, you can use the following BAPI. This BAPI extracts the Customer's Address, General Data, Company Code Data and the Bank Details.

SAP ABAP to get customer Bank Details   
BAPI_CUSTOMER_GETDETAIL2

For reference please find below the transaction codes to Create/Change/Display a customer

XD01 Create Customer Complete
XD02 Change Customer Complete
XD03 Display Customer Complete

VD01 Create Customer Sales and Distribution
VD02 Change Customer Sales and Distribution
VD03 Display Customer Sales and Distribution


Also Find below the tables related to the BAPI BAPI_CUSTOMER_GETDETAIL2

KNBK-Customer Master (Bank Details)
ADRC- Addresses (central address admin.)
KNA1-General Data in Customer Master
KNB1-Customer Master (Company Code)

The following code extracts the above mentioned details from the SAP R/3 System

REPORT ZEX_CUSTOMERBANK .


Parameters: p_kunnr like BAPICUSTOMER_ID-CUSTOMER,
            p_bukrs like BAPICUSTOMER_ID-COMP_CODE.

Data: ty_knbk type knbk,
      ty_custadd type BAPICUSTOMER_04,
      ty_custgendet type BAPICUSTOMER_KNA1,
      ty_custcompdet type BAPICUSTOMER_05,
      d_ret         like BAPIRET1.

Data: wa_custadd like ty_custadd,
      wa_custgendet like ty_custgendet,
      wa_custcompdet like ty_custcompdet.


Data: int_knbk like ty_knbk occurs 0.


CALL FUNCTION 'BAPI_CUSTOMER_GETDETAIL2'
  EXPORTING
    CUSTOMERNO                  = p_kunnr
   COMPANYCODE                  = p_bukrs
 IMPORTING
   CUSTOMERADDRESS              = wa_custadd
   CUSTOMERGENERALDETAIL        = wa_custgendet
   CUSTOMERCOMPANYDETAIL        = wa_custcompdet
   RETURN                       = d_ret
 TABLES
   CUSTOMERBANKDETAIL           = int_knbk      .


   if sy-subrc = 0.

   Endif.

SAP ABAP BAPI to Read Customer Data

SAP ABAP BAPI to Read Customer Data

In case you wish to read the customer data you can use the following BAPI, it retrieves the Customer Master (Company Code) Data and the General Data in Customer Master.

SAP ABAP BAPI to Read Customer Master Data
CUSTOMER_READ

You need to pass the Customer Number and the Company Code. See the example given below.


REPORT ZEX_CUSTOMERREAD .

Parameters: p_bukrs like KNB1-BUKRS,
            p_kunnr like KNA1-KUNNR.


Data: ty_kna1 type kna1,
      ty_knb1 type knb1.

Data: int_kna1 like ty_kna1,
      int_knb1 like ty_knb1.

CALL FUNCTION 'CUSTOMER_READ'
  EXPORTING
    I_BUKRS         = p_bukrs
    I_KUNNR         = p_kunnr
 IMPORTING
   E_KNA1          = int_Kna1
   E_KNB1          = int_knb1
 EXCEPTIONS
   NOT_FOUND       = 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.


Wednesday, May 28, 2008

SAP ABAP Random Number Generator

SAP ABAP Random Number Generator

If you wish to generate a Random Number in ABAP you can use the following function module.

QF05_RANDOM_INTEGER

Here you need to input 2 numbers ie the upper limit and the lower limit. This works only for integers.

Please find the code below.

REPORT ZEX_RANDOMNUMBER .

Parameters: p_larg like QF00-RAN_INT,
            p_small like QF00-RAN_INT.

Data: d_result like QF00-RAN_INT.

CALL FUNCTION 'QF05_RANDOM_INTEGER'
 EXPORTING
   RAN_INT_MAX         = p_larg
   RAN_INT_MIN         = p_small
 IMPORTING
   RAN_INT             = d_result
 EXCEPTIONS
  INVALID_INPUT       = 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:/ 'The Number is = ' , d_result.



If you enter  100 and 5 then  the result would be any number between 5 and 100 inclusive of 5 and 100.

 

SAP IDOC

SAP IDOC

Basically an IDOC is formed of segments, and comprises of IDOC Type and IDOC Data. IDOC types defines the structure and format of the data being exchanged. You can see in the figure below how an IDOC is represented in the SAP system. Please note that when you are looking at an IDOC of Sales Order, the generated IDOC will have all the data stored in the Sales Order, also there are means of filtering out the data that you do not want to include in the IDOC or you can also include some addition data. The actual Sales Order will be saved in the tables associated with Sales Order example VBAK, VBAP etc. Where as the generated IDOC will be stored separately.

Typically an IDOC will have the following
  • Control Record
  • Data Records
  • Status Records
Please see the figure given below.



Control Record:

Will have all the following.
  • IDOC number
  • IDOC TYPE
  • Sender and Receiver Information
  • Message Type
Please note that there is only one control record per IDOC and the structure of IDOC control record is the same for all IDOCs.

Data Record:

This basically contains the data, the header data and the line item data for a particular IDOC for example Sales Order or Purchase Order. These are multiple records.

Status Record:

This represents the different status the IDOC goes through. And a status record will have multiple statuses. A status code, Date and Time are assigned.

Tuesday, May 27, 2008

SAP EDI Process Overview

SAP EDI Process Overview





In any SAP EDI Process a Sub System is required. Basically an EDI Subsystem does the conversion of SAP IDOCs to to EDI fromat and Vice Versa. An EDI subsystem is a thirdparty systems and deals with standards that are most current. Thus as mentioned above the EDI SubSystem acts like a translator. SAP does certify some EDI subsystems and this is based on the version of SAP.

Basically the SAP EDI process is comprised of

OutBound Process
InBound Process

OutBound Process

The OutBound Document is Created. This could be a Sales Order or a Purchase Order or an Invoice. The process of creating the document is no different than the normal way. But prior to this IDOC configuration is made so that on the document is saved an IDOC is generated. The document is saved in the SAP tables in the usual way but in addition to that an IDOC with the same data is also generated and saved. You can view this IDOC using the appropriate transactions.  Example  WE05 --- IDOC List WE02 Display IDOC. Once the IDOC is generated it is transferred to the operating system level for the EDI system to pick it up. Further to this the IDOC is converted to the EDI standards and the IDOC is then transferred to the desired Partner. The status of this transaction is sent back to SAP.

SAP Purchasing Documents

SAP Purchasing Documents

The following types of Purchasing Documents are present in SAP.

Request For Quotation (RFQ).

This document is sent to the potential vendor. This basically is a request to the vendor to send the quotation for a material or a service.

OutBound Process
From Company ----------------------- Vendor
From SAP -------------------------------- Non SAP/SAP

Related Transactions: Create ME41, Change ME42, Display ME43, Maintain Supplement ME44, Release ME45
List Display:                By Vendor ME4L, ME4M by Material, By Service MSRV4, By Collective Number ME4S, By Material Group ME4C,
                                   By Tracking Number ME4B, By RFQ Number ME4N, Transaction Per Tracking Number MELB.
Reporting:                  General Analysis ME80AN, Archived Purchasing Documents ME82            


Quotation.

When the receives the RFQ he responds to it by sending the Quotation. The quotation basically contains the prices and conditions and helps in selecting the Vendor.

InBound Process
Vendor ------------------------------- Company
Non SAP/SAP ---------------------- SAP

Related Transactions: Maintain ME47, Display ME48, Price Comparison ME49.

Purchase Order

This is basically a document that makes request for buying the material or service. the vendor does that supply the material or does not provide the service till the point he receives this document. This document formalizes a purchase transaction.

OutBound Process
From Company ----------------------- Vendor
From SAP -------------------------------- Non SAP/SAP

Related Transactions: Create (Vendor/Supplying Plant Known) ME21N, Vendor Unknown ME25, Via Requisition List ME58, Automatically via Purchase Requisitions ME59. Change ME22N, Display ME23N, Maintain Supplement ME24, Release ME28,  Mass Maintenance MEMASSPO.

List Displays: By Vendor ME2L, BY Material ME2M, By Material Group ME2C, By Tracking Number ME2B, By PO Number ME2N, By Supplying Plant ME2W, Transactions per Tracking Number MELB.

For Account Assignment: General ME2K, By Project ME2J.

Reporting: General Analysis ME80FN, Analysis of Order Values ME81N, Achieved Purchasing Documents ME82, SC Stocks per Vendor ME20, Monitor Confirmations ME2A


Contract

This is basically a 'CONTRACT' between the vendor (external entity) and the Company (SAP) and is a legal binding for buying certain material or service over a period of time. The time is specified.

OutBound Process
From Company ----------------------- Vendor
From SAP -------------------------------- Non SAP/SAP

Related Transactions: Create ME31K, Change ME32K, Display ME33K, Maintain Supplement ME34K, Release ME35K


Scheduling Agreement

This is an agreement, or a long term buying arrangement. Basically it defines the delivery schedules. It provides for the creation of delivery schedules and specifies purchase quantities, delivery dates, and defines precise times of delivery over a predefined period.

OutBound Process
From Company ----------------------- Vendor
From SAP -------------------------------- Non SAP/SAP

Related Transactions: Create Vendor Known ME31L, Stock Transport Scheduling Agreement ME37, Change ME32L, Display ME33L, Maintain Supplement ME34L, Release ME35L