BAPI Sample To Upload Data From Flat File To VA01

SAP Functional ==> ABAP

Which BAPI to upload data from a flat file to VA01?

Use the BAPI's
BAPI_SALESORDER_CREATEFROMDAT1
BAPI_SALESORDER_CREATEFROMDAT2

This will create the Sales order .
*---------------------------------------------------------------------
Include YCL_CREATE_SALES_DOCU * 
*---------------------------------------------------------------------

Form salesdocu 
*---------------------------------------------------------------------
*This Subroutine is used to create Sales Order 
*----------------------------------------------------------------------

*-->P_HEADER Document Header Data 
*-->P_HEADERX Checkbox for Header Data 
*-->P_ITEM Item Data 
*-->P_ITEMX Item Data Checkboxes 
*-->P_LT_SCHEDULES_IN Schedule Line Data 
*-->P_LT_SCHEDULES_INX Checkbox Schedule Line Data 
*-->P_PARTNER text Document Partner 
*<--P_w_vbeln text Sales Document Number 

*---------------------------------------------------------------------
DATA:
lfs_return like line of t_return.
 

FORM create_sales_document changing P_HEADER like fs_header
P_HEADERX like fs_headerx
Pt_ITEM like t_item[]
t_ITEMX like t_itemx[]
P_LT_SCHEDULES_IN like t_schedules_in[]
P_LT_SCHEDULES_INX like t_schedules_inx[]
Pt_PARTNER like t_partner[]
P_w_vbeln like w_vbeln.

*This Perform is used to fill required data for Sales order creation 
perform sales_fill_data changing p_header

p_headerx
pt_item
pt_itemx
p_lt_schedules_in
p_lt_schedules_inx
pt_partner.

*Function Module to Create Sales and Distribution Document 

perform sales_order_creation using p_header
p_headerx
pt_item
pt_itemx
p_lt_schedules_in
p_lt_schedules_inx
pt_partner.

perform return_check using p_w_vbeln .

ENDFORM. " salesdocu

*---------------------------------------------------------------------
*Form commit_work 
*---------------------------------------------------------------------
*To execute external commit * 
*---------------------------------------------------------------------

FORM commit_work .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = c_x.

ENDFORM. " Commit_work

Include ycl_sales_order_header " To Fill Header data and Item data 
Include ycl_sales_order_header.

*---------------------------------------------------------------------
Form return_check 
*---------------------------------------------------------------------
To validate the sales order creation 
*---------------------------------------------------------------------

FORM return_check using pr_vbeln type vbeln.
if pr_vbeln is initial.
LOOP AT t_return into lfs_return .
WRITE / lfs_return-message.
clear lfs_return.

ENDLOOP. " Loop at return
else.
perform commit_work. " External Commit
 

Refresh t_return.

fs_disp-text = text-003.
fs_disp-number = pr_vbeln.
append fs_disp to it_disp.
 

if p_del eq c_x or p_torder eq c_x or
p_pgi eq c_x or p_bill eq c_x.
perform delivery_creation. " Delivery order creation

endif. " If p_del eq 'X'......

endif. " If p_w_vbeln is initial

 ENDFORM. " Return_check

*&---------------------------------------------------------------------
*& Form sales_order_creation
*&---------------------------------------------------------------------
*text 
*----------------------------------------------------------------------

*-->P_P_HEADER text 
*-->P_P_HEADERX text 
*-->P_PT_ITEM text 
*-->P_PT_ITEMX text 
*-->P_P_LT_SCHEDULES_IN text 
*-->P_P_LT_SCHEDULES_INX text 
*-->P_PT_PARTNER text 
*----------------------------------------------------------------------

FORM sales_order_creation USING P_P_HEADER like fs_header
P_P_HEADERX like fs_headerx
P_PT_ITEM like t_item[]
P_PT_ITEMX like t_itemx[]
P_P_LT_SCHEDULES_IN like t_schedules_in[]
P_P_LT_SCHEDULES_INX like t_schedules_inx[]
P_PT_PARTNER like t_partner[].

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING

sales_header_in = p_p_header
sales_header_inx = p_p_headerx

IMPORTING
salesdocument_ex = w_vbeln

TABLES
return = t_return
sales_items_in = p_pt_item
sales_items_inx = p_pt_itemx
sales_schedules_in = p_p_lt_schedules_in
sales_schedules_inx = p_p_lt_schedules_inx
sales_partners = p_pt_partner.

ENDFORM. " sales_order_creation

-----------

In BAPI_salesorder_createfromdat2 what is the significance of importing parameter order_header_inx.
What does 'X' signify?

This parameter fulfills the following two tasks:

Controls processing functions with the value in the UPDATEFLAG field (change indicator).
The following entries are available:
' ' : Create a new sales document
I: Create a new sales document
U: Change an existing sales document
D: Delete an existing sales document

Controls the field entry with checkboxes
If the UPDATEFLAG field has been activated, the system only copies those fields from the SALES_HEADER_IN parameter that have been activated with 'X'.

See Also:
Help on Conversion From Numbers to Text Amount

More Function Module
Functions / SAP Script / ALV

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.