Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

data upload using BAPI

Former Member
0 Likes
1,052

hi experts,

how to upload the data for sales order using BAPI.

it would be much helpful if i have the sample code.

thanks and Regards

5 REPLIES 5
Read only

Former Member
0 Likes
712

Hi,

See the sample code:

FORM ORDER_CREATE_BAPI.

  • SD_ORDER_ITEMS_IN

REFRESH SD_ORDER_ITEMS_IN.

LOOP AT QUOTA_TAB.

SD_ORDER_ITEMS_IN-PO_ITM_NO = QUOTA_TAB-POSEX.

SD_ORDER_ITEMS_IN-MATERIAL = QUOTA_TAB-MATNR.

QUOTA_TAB-WMENG = QUOTA_TAB-WMENG * 1000.

SD_ORDER_ITEMS_IN-REQ_QTY = QUOTA_TAB-WMENG.

APPEND SD_ORDER_ITEMS_IN.

ENDLOOP.

  • es kann sein, dass wegen Fehlermeldungen weniger Positionen im

  • Angebot stehen. In diesem Fall muessen auch die ueberfluessigen

  • Konfigurationstabellen geloescht werden

LOOP AT BASKET_TAB.

CHECK BASKET_TAB-KZKFG EQ YES.

READ TABLE QUOTA_TAB

WITH KEY BASKET_TAB-POSEX.

IF SY-SUBRC > 0.

PERFORM CONFIGURATION_DELETE_ORDER USING BASKET_TAB-POSEX.

ENDIF.

ENDLOOP.

  • SD_ORDER_PARTNERS

REFRESH SD_ORDER_PARTNERS.

SD_ORDER_PARTNERS-PARTN_ROLE = 'AG'.

SD_ORDER_PARTNERS-PARTN_NUMB = XLOGIN-KUNNR.

APPEND SD_ORDER_PARTNERS.

  • SD_ORDER_HEADER

CLEAR SD_ORDER_HEADER.

SD_ORDER_HEADER-DOC_TYPE = ORDER_TYPE.

SD_ORDER_HEADER-SALES_ORG = SALES_ORGANIZATION.

SD_ORDER_HEADER-DISTR_CHAN = DISTRIBUTION_CHANNEL.

SD_ORDER_HEADER-DIVISION = DIVISION.

SD_ORDER_HEADER-SALES_OFF = SALESOFFICE.

  • Vorschlagsdatum

SD_ORDER_HEADER-REQ_DATE_H = SY-DATLO.

IF TVAK-DATVO EQ CHARX.

SD_ORDER_HEADER-REQ_DATE_H = SY-DATLO + TVAK-VLAUF.

ENDIF.

IF SD_ORDER_HEADER-DATE_TYPE IS INITIAL.

IF TVAK-KPRGBZ NE SPACE.

SD_ORDER_HEADER-DATE_TYPE = TVAK-KPRGBZ.

ELSE.

SD_ORDER_HEADER-DATE_TYPE = CHAR1.

ENDIF.

ENDIF.

  • Vorschlagsdatum pruefen auf Sonn- bzw. Feiertag

  • perform vbkd_datum_pruefen(sapfv45k)

  • using sd_order_header-req_dlv_dt.

CONCATENATE 'WWW' SY-UZEIT(2) SY-UZEIT2(2) SY-UZEIT4(2)

INTO SD_ORDER_HEADER-PURCH_NO SEPARATED BY ':'.

SD_ORDER_HEADER-PURCH_DATE = SY-DATUM.

SD_ORDER_HEADER-PRICE_DATE = SY-DATUM.

CLEAR RETURN1.

  • CREATE_ORDER

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'

EXPORTING

ORDER_HEADER_IN = SD_ORDER_HEADER

IMPORTING

RETURN = RETURN1

SALESDOCUMENT = ORDER_NUMBER

SOLD_TO_PARTY = SD_SOLD_TO_PARTY

SHIP_TO_PARTY = SD_SHIP_TO_PARTY

BILLING_PARTY = SD_BILLING_PARTY

TABLES

ORDER_ITEMS_IN = SD_ORDER_ITEMS_IN

ORDER_PARTNERS = SD_ORDER_PARTNERS

ORDER_ITEMS_OUT = SD_ORDER_ITEMS_OUT

ORDER_CFGS_REF = SD_ORDER_CFGS_REF

ORDER_CFGS_INST = SD_ORDER_CFGS_INST

ORDER_CFGS_PART_OF = SD_ORDER_CFGS_PART_OF

ORDER_CFGS_VALUE = SD_ORDER_CFGS_VALUE

ORDER_CCARD = SD_ORDER_CCARD.

IF NOT RETURN1 IS INITIAL.

MESSAGE W205 WITH RETURN.

EXIT.

ENDIF.

WRITE ORDER_NUMBER TO XORDER-VBELN.

ENDFORM.

Regards,

Anji

Read only

0 Likes
712

i want to use bapi which exits .......

and i have the legacy data in the form of flat file(eg notepad)......

can you provide the solution for this.........

Read only

Former Member
0 Likes
712

Hi Charles,

Use FM GUI_UPLOAD.

Regards,

John.

Read only

Former Member
0 Likes
712

hi

good

try this

check the data element of the fields in the Bapi interface. In most cases they coincide with the data elements of the fields in VA02.

Best thing is to look at the help on the Bapi. What version SAP are you on? if it is recent enough you can call tcode BAPI and you get a lot of help for the fields and even authorizations needed.

if you are on 46c better use BAPI_SALESORDER_CREATEFROMDAT2 which is more complete. But be careful because you need to also call BAPI_TRANSACTION_COMMIT or else no order in SAP.

thanks

mrutyun^

Read only

0 Likes
712

Hey in any case you have to convert the data from the flat file into the table format and then only you cna upload it to sap.no direct upload is possible to the transaction.first upload into sap using gui_upload if its already there in the unix server use open dataset to read the file and then use the bapi to populate it inot the transaction

Regards,

sasi