Friday, 29 July 2016

Calling BAPIs from SAP-ABAP ( Ex : BAPI_SALESORDER_GETSTATUS )

Steps

  • To find BAPI , go to transaction code BAPI.
  • Click on "Sales and Distribution " -> Sales -> SalesOrder ->GetStatus.
  • Go to Transaction Code SE38.
  • Enter the program name start's with Y or Z<Program name > and click on Create.
  • Enter the Title.
  • Select the Attribute type as Executable Program.
  • Click on SAVE.



Source Code


DATA : RETURN LIKE  BAPIRETURN,
      WA_INFO TYPE  BAPISDSTAT,
      IT_INFO TYPE TABLE OF BAPISDSTAT.

PARAMETERS : P_VBELN TYPE VBAK-VBELN.


CALL FUNCTION 'BAPI_SALESORDER_GETSTATUS'
  EXPORTING
    SALESDOCUMENT       =  P_VBELN
 IMPORTING
   RETURN              =  RETURN
 TABLES
   STATUSINFO          = IT_INFO
          .

IF RETURN IS INITIAL.


  WRITE : / 'Doc Number' COLOR 3 , 20 'PO Number' , 40 'Status',
           50 'DelV Status ' , 65 'Items' , 80 'Material' ,
           90 'Net Price' COLOR 6.
  WRITE : / SY-ULINE(100).


  LOOP AT IT_INFO INTO WA_INFO.

   WRITE : / WA_INFO-DOC_NUMBER ,
           20 WA_INFO-PURCH_NO,
           40 WA_INFO-PRC_STAT_H,
           50 WA_INFO-DLV_STAT_H,
           65 WA_INFO-ITM_NUMBER,
           80 WA_INFO-MATERIAL,
           90 WA_INFO-NET_PRICE LEFT-JUSTIFIED.
  ENDLOOP.


  ELSE.

    WRITE : / RETURN-MESSAGE.


ENDIF.


  • Save -> Check -> Activate.
  • Execute.

Input - 1

  • Enter Sales Document Number.
  • Execute ( F8 ).

Input - 2

  • Without Input.
  • Execute ( F8 ).


No comments:

Post a Comment