2007 Mar 14 6:26 AM
hi experts,
i want to upload the sales order using BAPI.
can you provide the FM.
it will be much helpful if i have the sample code........
thanks
2007 Mar 14 6:39 AM
Hi Shyam,
Use BAPI : BAPI_SALESORDER_CREATEFROMDAT2
REPORT ZZBAPI_TEST1 .
*===========================================================
*** Start of selection
*===========================================================
START-OF-SELECTION.
* test of sales order with BAPI
PERFORM SALES_ORDER_BAPI.
*================ End of main program ======================
*&---------------------------------------------------------------------*
*& Form SALES_ORDER_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SALES_ORDER_BAPI.
DATA : SD_HEADER LIKE BAPISDHEAD.
DATA : BEGIN OF ITEMIN_IT OCCURS 1.
INCLUDE STRUCTURE BAPIITEMIN.
DATA : END OF ITEMIN_IT.
DATA : BEGIN OF PARTNR_IT OCCURS 1.
INCLUDE STRUCTURE BAPIPARTNR.
DATA : END OF PARTNR_IT.
DATA : WK_SD_DOCNO LIKE VBAK-VBELN.
DATA: WK_RETURN LIKE BAPIRETURN.
CLEAR : SD_HEADER , ITEMIN_IT , PARTNR_IT.
SD_HEADER-DOC_TYPE = 'TA'.
SD_HEADER-SALES_ORG = '1793'.
SD_HEADER-DISTR_CHAN = '01'.
SD_HEADER-DIVISION = '01'.
SD_HEADER-PURCH_NO = 'Test'.
* itemin_it-hg_lv_item = '10'.
ITEMIN_IT-MATERIAL = '000000000000001143'.
ITEMIN_IT-PLANT = '3018'.
ITEMIN_IT-REQ_QTY = '1'.
ITEMIN_IT-SALES_UNIT = 'CS'.
APPEND ITEMIN_IT.
* itemin_it-hg_lv_item = '20'.
ITEMIN_IT-MATERIAL = '000000000000000848'.
ITEMIN_IT-PLANT = '3018'.
ITEMIN_IT-REQ_QTY = '1'.
ITEMIN_IT-SALES_UNIT = 'KG'.
APPEND ITEMIN_IT.
* itemin_it-hg_lv_item = '30'.
ITEMIN_IT-MATERIAL = '000000000000000848'.
ITEMIN_IT-PLANT = '3018'.
ITEMIN_IT-REQ_QTY = '1'.
ITEMIN_IT-SALES_UNIT = 'EA'.
APPEND ITEMIN_IT.
LOOP AT ITEMIN_IT.
WRITE : / SY-TABIX , ITEMIN_IT-MATERIAL , ITEMIN_IT-PLANT
, ITEMIN_IT-REQ_QTY , ITEMIN_IT-SALES_UNIT.
ENDLOOP.
CLEAR : PARTNR_IT.
PARTNR_IT-PARTN_ROLE = TEXT-001.
PARTNR_IT-PARTN_NUMB = '0000000004'.
APPEND PARTNR_IT.
CLEAR : PARTNR_IT.
PARTNR_IT-PARTN_ROLE = 'WE'.
PARTNR_IT-PARTN_NUMB = '0000000051'.
APPEND PARTNR_IT.
LOOP AT PARTNR_IT.
WRITE : / SY-TABIX , PARTNR_IT-PARTN_ROLE , PARTNR_IT-PARTN_NUMB.
ENDLOOP.
CLEAR : ITEMIN_IT , PARTNR_IT , WK_RETURN..
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDATA'
EXPORTING
ORDER_HEADER_IN = SD_HEADER
IMPORTING
SALESDOCUMENT = WK_SD_DOCNO
* SOLD_TO_PARTY =
* SHIP_TO_PARTY =
* BILLING_PARTY =
RETURN = WK_RETURN
TABLES
ORDER_ITEMS_IN = ITEMIN_IT
ORDER_PARTNERS = PARTNR_IT
* ORDER_ITEMS_OUT =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CCARD =
EXCEPTIONS
OTHERS = 1.
WRITE : / 'sy-subrc = ' , SY-SUBRC.
IF NOT WK_SD_DOCNO IS INITIAL.
WRITE : / WK_SD_DOCNO , 'registerd'.
ELSE.
WRITE : / 'incorrect'.
WRITE : / WK_RETURN-TYPE , WK_RETURN-CODE , WK_RETURN-MESSAGE.
WRITE : / WK_RETURN-LOG_NO, WK_RETURN-LOG_MSG_NO,
WK_RETURN-MESSAGE_V1.
ENDIF.
ENDFORM. " SALES_ORDER_BAPI
Hope that helps.
Regards
Kapadia
***Assigning points is the way to say thanks in SDN.***
Message was edited by:
Mr Kapadia
2007 Mar 14 6:58 AM
thanks a lot for your sample code.
but if i have the flat file(notepad or excel) how to upload the data using BAPI.
2007 Jul 18 4:02 AM
what if i want to enter characteristics values? what should i put in ORDER_CFGS_VALUE? and where can i get the data? thnx