SAP ABAP Tutorial: Module Pool Programming. Part 3
We will now proceed further and see the code that needs to be put in place to actually create the sales order.
Code for the PBO Module
*&---------------------------------------------------------------------*
*& Module pool ZSALESORDSCREEN *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
INCLUDE ZSALESORDERTOP . "
* INCLUDE ZSALESORDERO01 . *
* INCLUDE ZSALESORDERI01 . *
* INCLUDE ZSALESORDERF01 . *
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'ZSALES'.
SET TITLEBAR 'ZSL'.
ENDMODULE. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9000 INPUT.
CASE OK_CODE.
When 'BACK'.
leave to screen 0.
When 'ORDE'.
Perform Create_Salesord.
leave to screen 0.
endcase.
ENDMODULE. " USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
*& Form Create_Salesord
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM Create_Salesord.
*-------------------------Data Declaration-----------------------------*
Data: st_BAPISDHEAD like BAPISDHEAD, " Sales Order Header Data
ta_BAPIITEMIN like BAPIITEMIN occurs 0 with header line, " Ln item
ta_BAPIPARTNR like BAPIPARTNR occurs 0 with header line, " Partner
d_BAPIRETURN1 like BAPIRETURN1, " Bapi return msg
d_vbeln like bapivbeln-VBELN. " Sales Order Number
* Move the data to create sales order in the repective parameters------*
move: txtordtype to st_BAPISDHEAD-DOC_TYPE, " Sales document type
txtpurchord to st_BAPISDHEAD-PURCH_NO_C,
* '00010' to ta_BAPIITEMIN-ITM_NUMBER,
txtmatno to ta_BAPIITEMIN-MATERIAL,
* '1100' to ta_BAPIITEMIN-PLANT,
txtqty to ta_BAPIITEMIN-REQ_QTY,
'AG' to ta_BAPIPARTNR-PARTN_ROLE, " Sold to Party
txtsoldto to ta_BAPIPARTNR-PARTN_NUMB.
* Append the internal tables-------------------------------------------*
append ta_BAPIPARTNR.
clear ta_BAPIPARTNR.
append ta_BAPIITEMIN.
clear ta_BAPIITEMIN.
* Move ship to party---------------------------------------------------*
move: 'RG' to ta_BAPIPARTNR-PARTN_ROLE, " Ship to party
txtshipto to ta_BAPIPARTNR-PARTN_NUMB.
* Append the internal tables-------------------------------------------*
append ta_BAPIPARTNR.
clear ta_BAPIPARTNR.
* Call the Bapi to create the sales order
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
EXPORTING
ORDER_HEADER_IN = st_BAPISDHEAD
* WITHOUT_COMMIT = ' '
* CONVERT_PARVW_AUART = 'X'
IMPORTING
SALESDOCUMENT = d_vbeln
* SOLD_TO_PARTY =
* SHIP_TO_PARTY =
* BILLING_PARTY =
RETURN = d_BAPIRETURN1
TABLES
ORDER_ITEMS_IN = ta_BAPIITEMIN
ORDER_PARTNERS = ta_BAPIPARTNR
* ORDER_ITEMS_OUT =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CCARD =
* ORDER_CFGS_BLOB =
* ORDER_SCHEDULE_EX =
.
if d_vbeln <> space.
* Message I001.
* Message I002 with D_vbeln.
Message ID 'ZEXERCISE2' TYPE 'S' Number '000'.
* write: 'Sales order No. ', d_vbeln.
endif.
ENDFORM. " Create_Salesord
*&---------------------------------------------------------------------*
*& Include ZSALESORDERTOP *
*& *
*&---------------------------------------------------------------------*
PROGRAM ZSALESORDSCREEN .
Data: ok_code(4),
txtordtype(2),
txtsoldto(10),
txtshipto(10),
txtpurchord(10),
txtmatno(18),
txtqty(13).
Hey i could'nt understand what exactly its doing . its activated.
ReplyDeletedo i need to create a database table?
after entering the values where does it stores?