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

help on bapi urgent

Former Member
0 Likes
941

hi sap geeks

can u plz tell me that i have a bapi code for va01.....do we have to do recording for bapi or directly i should type it in se38...and how to upload the whole dta thru this code as in this code only certain fields are initilized...plz let me know as soon as possible ...below is the give code.

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

hi sap geeks

can u plz tell me that i have a bapi code for va01.....do we have to do recording for bapi or directly i should type it in se38...and how to upload the whole dta thru this code as in this code only certain fields are initilized...plz let me know as soon as possible ...below is the give code.

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

6 REPLIES 6
Read only

Former Member
0 Likes
912

first step

gui_upload

1223

1233

loop at itab into wa.

  • test of sales order with BAPI

PERFORM SALES_ORDER_BAPI.

commit work.

endloop.

Read only

0 Likes
912

seems good answer but can u give in detail

thnks

Read only

dev_parbutteea
Active Contributor
0 Likes
912

Hi,

You have to do a recording when using call transaction only!

When using bapi's , you should verify the mandatory parameters to pass i the bapi documentation.

Regards,

Sooness.

Read only

Former Member
0 Likes
912

Hi,

You dont need to record anything. BAPI is just like Function Module. To which you have to fullfill all the parameters and Run the Program.

In your case, you are populating data into internal tables and Work areas and providing it to the,

'BAPI_SALESORDER_CREATEFROMDATA'

Which is ultimetly creates your order. No need to upload.

Just ensure that after this call , call FM BAPI_TRANSACTION_COMMIT

Reward if useful!

Read only

Former Member
0 Likes
912

hi,

there is no need to do recording if u use bapis coz it hits the database

directly through structures .

The thing that is important when u use bapi is what are the parameters that u must pass to the function modulte(bapi is nothing but a function module but a remote enabled f.m.)

regards

sreekanth

Read only

Former Member
0 Likes
912

Hi,

Please read this it will help u.

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least the order header data (from the ORDER_HEADER_IN structure) as well as partner data (using the ORDER_PARTNERS table) as input parameters.

Enter item data using the ORDER_ITEMS_IN table. You can allocate the item number by filling in the relevant fields manually, or the system does it according to the settings in Customizing, whereby the relevant fields remain blank.

If the item is configurable, you need to enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

You can use the BAPICCARD structure to enter credit card data. You can either enter data for identifying the card or, you can enter data for an authorization in an external system.

Once you have successfully created the sales order, the system displays the document number (in the SALESDOCUMENT field), as well as detailed data about the other parties (in the OLD_TO_PARTY, SHIP_TO_PARTY and BILLING_PARTY structures). The RETURN parameter displays any errors that may have occured.

The ORDER_ITEMS_OUT table contains more detailed information that will enable you to judge the pricing and availability of an item.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner functions, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

REQ_QTY Order quantity in sales unit

2. Ship-to party

If a ship-to party hasn't been entered, the ship-to party = sold-to

party

3. COMMIT control:Parameter WITHOUT_COMMIT

If this switch is activated, the system does not process any Commit Work and the application that has called it up must trigger the Commit itself. To do this, useBAPI_TRANSACTION_COMMIT.

4. German keywords:

The following keywords must be entered in German, regardless of the

logon language:

DOC_TYPE Sales document type, for example TA for standard order

PARTN_ROLE Partner function, for example, WE for ship-to party