Application Development 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: 

BDC for purchase order

Former Member
0 Kudos

Hi Guys,

I am trying to upload purchase order data using BDC call transaction method but while I was creating the purchase order there is a field "Incoterms" on the item level additional data screen, as soon as I go on that screen it shows me a message that "please enter the value in the required fields" and this message is coming in the recoding as well and it's creating problem, can you please tell me how to get rid of this message.

Thanks

Rajeev Gupta

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

use BAPI_PO_CREATE1.

check this Sample code it will help you

REPORT zpo_create .

PARAMETERS: p-file LIKE rlgrap-filename DEFAULT

'c:\demo3.txt'.

DATA: BEGIN OF itab OCCURS 0,

line(1000),

END OF itab.

DATA l_item(5) TYPE n.

TABLES : zerror.

DATA lcounter(3) TYPE n.

DATA : l_errflag.

DATA : l_po_header LIKE bapimepoheader.

DATA : l_po_headerx LIKE bapimepoheaderx.

DATA : t_po_account LIKE bapimepoaccount OCCURS 0 WITH HEADER LINE.

DATA : t_po_accountx LIKE bapimepoaccountx OCCURS 0 WITH HEADER LINE.

DATA : l_new_po(10), l_last_po(10).

DATA : l_purchaseorder LIKE bapimepoheader-po_number.

*DATA : L_HEADER LIKE BAPIMEPOHEADER STRUCTURE BAPIMEPOHEADER.

DATA : BEGIN OF t_po_items OCCURS 0.

INCLUDE STRUCTURE bapimepoitem.

DATA : END OF t_po_items.

DATA : BEGIN OF t_po_itemsx OCCURS 0.

INCLUDE STRUCTURE bapimepoitemx.

DATA : END OF t_po_itemsx.

DATA : BEGIN OF t_return OCCURS 0.

INCLUDE STRUCTURE bapiret2.

DATA : END OF t_return.

CLEAR : l_po_header.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p-file

filetype = 'DAT'

TABLES

data_tab = itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

OTHERS = 6.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

EXIT.

ENDIF.

LOOP AT itab.

IF itab-line(1) EQ 'K'.

l_new_po = itab-line(10).

IF l_last_po NE l_new_po AND l_last_po NE space.

PERFORM create_po.

PERFORM refresh_table.

ENDIF.

IF itab-line+13(2) EQ '40'.

PERFORM append_header.

ENDIF.

IF itab-line+13(2) EQ '81'.

PERFORM append_item.

ENDIF.

l_last_po = l_new_po.

ENDIF.

ENDLOOP.

IF sy-subrc EQ 0.

PERFORM create_po.

PERFORM refresh_table.

ENDIF.

&----


*& Form CREATE_PO

&----


  • PO Create

----


  • --> p1 text

  • <-- p2 text

----


FORM create_po .

CLEAR : l_purchaseorder.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = l_po_header

poheaderx = l_po_headerx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

exppurchaseorder = l_purchaseorder

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

return = t_return

poitem = t_po_items

poitemx = t_po_itemsx

  • POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

poaccount = t_po_account

  • POACCOUNTPROFITSEGMENT =

poaccountx = t_po_accountx

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

.

l_errflag = space.

lcounter = 1.

LOOP AT t_return .

IF t_return-type = 'E'.

l_errflag = 'X'.

GET TIME.

PERFORM append_error.

ENDIF.

WRITE : /1 t_return-message.

ENDLOOP.

IF l_errflag EQ space.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDIF.

ENDFORM. " CREATE_PO

&----


*& Form APPEND_HEADER

&----


  • PO Header print

----


  • --> p1 text

  • <-- p2 text

----


FORM append_header .

l_po_header-comp_code = '1000'." Company Code

l_po_header-doc_type = 'NB'. " Order Typr BSART

l_po_header-creat_date = sy-datum. " P.O Dt - BEDAT

*CONCATENATE '0000' ITAB+72(6) INTO L_PO_HEADER-VENDOR .

l_po_header-vendor = itab-line+71(6).

*L_PO_HEADER-VENDOR = ITAB+72(6) " 'ABC'. "Vendor - EKKO-LIFNR

IF itab-line(4) NE 'K034'.

l_po_header-purch_org = '2000'. " Purch. Org - EKKO-EKORG

l_po_header-pur_group = 'F01'. " Purch Group - EKKO-EKGRP

ELSE.

l_po_header-purch_org = '1000'. " Purch. Org - EKKO-EKORG

l_po_header-pur_group = '001'. " Purch Group - EKKO-EKGRP

ENDIF.

l_po_header-currency_iso = 'USD'. " Currency Default field for Enjoy

l_po_header-ref_1 = itab-line+1(9).

*L_PO_HEADER-DOC_CAT = 'F'. " Account Assign Cat EKPO-KNTTP

*_PO_HEADER-CREATED_BY = SY-UNAME.

CLEAR : l_po_headerx.

l_po_headerx-po_number = 'X'.

l_po_headerx-comp_code = 'X'." Company Code

l_po_headerx-doc_type = 'X'. " Order Typr BSART

l_po_headerx-vendor = 'X'. "Vendor - EKKO-LIFNR

l_po_headerx-purch_org = 'X'. " Purch. Org - EKKO-EKORG

l_po_headerx-pur_group = 'X'. " Purch Group - EKKO-EKGRP

l_po_headerx-currency_iso = 'X'. " Currency Default field for Enjoy

l_po_headerx-ref_1 = 'X'.

ENDFORM. " APPEND_HEADER

&----


*& Form APPEND_ITEM

&----


  • Material Number and Item print

----


  • --> p1 text

  • <-- p2 text

----


FORM append_item .

  • PO Line Items

l_item = l_item + 10.

t_po_items-po_item = l_item.

*T_PO_ITEMS-PO_ITEM = '00010'." Line Item No - EKPO-EBELP

*T_PO_ITEMS-SHORT_TEXT = 'KSR TEXT'." Line Item TEXT

CONCATENATE '00000000' itab-line+32(10) INTO t_po_items-material.

*T_PO_ITEMS-MATERIAL = '000000000000000043'. " Material No - EKPO-EMATN

CONCATENATE '00000000' itab-line+32(10) INTO t_po_items-ematerial.

t_po_items-plant = '2001'. " Plant - EKPO-WERKS

t_po_items-quantity = '1.000'.

t_po_items-net_price = '10.00'. " EKPO-NETPR

t_po_items-price_unit = '10 '.

*T_PO_ITEMS-TAX_CODE = 'A2'.

IF itab-line+0(4) EQ 'K034'.

t_po_items-acctasscat = 'R'.

t_po_items-plant = '1001'.

t_po_account-po_item = l_item.

t_po_account-profit_ctr = 'BR034'.

t_po_account-gl_account = '0000135075'.

  • T_PO_ACCOUNT-CO_AREA = '1000'.

APPEND t_po_account.

CLEAR t_po_account.

t_po_accountx-po_item = l_item.

t_po_accountx-profit_ctr = 'X'.

t_po_accountx-gl_account = 'X'.

  • T_PO_ACCOUNTX-CO_AREA = 'X'.

APPEND t_po_accountx.

CLEAR t_po_accountx.

ENDIF.

APPEND t_po_items.

CLEAR t_po_items.

t_po_itemsx-po_item = l_item.

t_po_itemsx-po_itemx = 'X'.

t_po_itemsx-acctasscat = 'X'.

t_po_itemsx-material = 'X'.

t_po_itemsx-ematerial = 'X'.

t_po_itemsx-plant = 'X'.

t_po_itemsx-quantity = 'X'.

t_po_itemsx-net_price = 'X'.

t_po_itemsx-price_unit = 'X'.

*T_PO_ITEMSX-TAX_CODE = 'X'.

APPEND t_po_itemsx.

CLEAR t_po_itemsx.

      • Second Line Item

ENDFORM. " APPEND_ITEM

&----


*& Form REFRESH_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM refresh_table .

REFRESH : t_po_items, t_po_itemsx.

CLEAR l_item.

ENDFORM. " REFRESH_TABLE

&----


*& Form append_error

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM append_error .

MOVE : sy-datum TO zerror-zdate,

sy-uzeit TO zerror-ztime,

itab+3(5) TO zerror-document_no,

t_return-message TO zerror-message.

lcounter = lcounter + 1.

zerror-counter = lcounter .

zerror-rec_type = itab-line(1).

MODIFY zerror. CLEAR zerror.

COMMIT WORK.

ENDFORM. " append_error

Also please check out the link below it will be helpful to you

http://web.mit.edu/sapr3/windocs/bpors03m.htm

http://www.finance.utoronto.ca/Page641.aspx

*********please reward points if the information is helpful to you********

8 REPLIES 8

gopi_narendra
Active Contributor
0 Kudos

Use the BAPI instead of using BDC

Make use of the BAPI BAPI_PO_CREATE to create PO and on how to use it go through the documentation.

Regards

Gopi

0 Kudos

Well I want to use BDC only.

can you tell me how to get rid of that Incoterm error, I mean can this thing be done by making some changes in the configuration of Purchase order.

Thanks

Former Member
0 Kudos

Hi,

use BAPI_PO_CREATE1.

check this Sample code it will help you

REPORT zpo_create .

PARAMETERS: p-file LIKE rlgrap-filename DEFAULT

'c:\demo3.txt'.

DATA: BEGIN OF itab OCCURS 0,

line(1000),

END OF itab.

DATA l_item(5) TYPE n.

TABLES : zerror.

DATA lcounter(3) TYPE n.

DATA : l_errflag.

DATA : l_po_header LIKE bapimepoheader.

DATA : l_po_headerx LIKE bapimepoheaderx.

DATA : t_po_account LIKE bapimepoaccount OCCURS 0 WITH HEADER LINE.

DATA : t_po_accountx LIKE bapimepoaccountx OCCURS 0 WITH HEADER LINE.

DATA : l_new_po(10), l_last_po(10).

DATA : l_purchaseorder LIKE bapimepoheader-po_number.

*DATA : L_HEADER LIKE BAPIMEPOHEADER STRUCTURE BAPIMEPOHEADER.

DATA : BEGIN OF t_po_items OCCURS 0.

INCLUDE STRUCTURE bapimepoitem.

DATA : END OF t_po_items.

DATA : BEGIN OF t_po_itemsx OCCURS 0.

INCLUDE STRUCTURE bapimepoitemx.

DATA : END OF t_po_itemsx.

DATA : BEGIN OF t_return OCCURS 0.

INCLUDE STRUCTURE bapiret2.

DATA : END OF t_return.

CLEAR : l_po_header.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p-file

filetype = 'DAT'

TABLES

data_tab = itab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

OTHERS = 6.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

EXIT.

ENDIF.

LOOP AT itab.

IF itab-line(1) EQ 'K'.

l_new_po = itab-line(10).

IF l_last_po NE l_new_po AND l_last_po NE space.

PERFORM create_po.

PERFORM refresh_table.

ENDIF.

IF itab-line+13(2) EQ '40'.

PERFORM append_header.

ENDIF.

IF itab-line+13(2) EQ '81'.

PERFORM append_item.

ENDIF.

l_last_po = l_new_po.

ENDIF.

ENDLOOP.

IF sy-subrc EQ 0.

PERFORM create_po.

PERFORM refresh_table.

ENDIF.

&----


*& Form CREATE_PO

&----


  • PO Create

----


  • --> p1 text

  • <-- p2 text

----


FORM create_po .

CLEAR : l_purchaseorder.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = l_po_header

poheaderx = l_po_headerx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

exppurchaseorder = l_purchaseorder

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

return = t_return

poitem = t_po_items

poitemx = t_po_itemsx

  • POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

poaccount = t_po_account

  • POACCOUNTPROFITSEGMENT =

poaccountx = t_po_accountx

  • POCONDHEADER =

  • POCONDHEADERX =

  • POCOND =

  • POCONDX =

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

.

l_errflag = space.

lcounter = 1.

LOOP AT t_return .

IF t_return-type = 'E'.

l_errflag = 'X'.

GET TIME.

PERFORM append_error.

ENDIF.

WRITE : /1 t_return-message.

ENDLOOP.

IF l_errflag EQ space.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDIF.

ENDFORM. " CREATE_PO

&----


*& Form APPEND_HEADER

&----


  • PO Header print

----


  • --> p1 text

  • <-- p2 text

----


FORM append_header .

l_po_header-comp_code = '1000'." Company Code

l_po_header-doc_type = 'NB'. " Order Typr BSART

l_po_header-creat_date = sy-datum. " P.O Dt - BEDAT

*CONCATENATE '0000' ITAB+72(6) INTO L_PO_HEADER-VENDOR .

l_po_header-vendor = itab-line+71(6).

*L_PO_HEADER-VENDOR = ITAB+72(6) " 'ABC'. "Vendor - EKKO-LIFNR

IF itab-line(4) NE 'K034'.

l_po_header-purch_org = '2000'. " Purch. Org - EKKO-EKORG

l_po_header-pur_group = 'F01'. " Purch Group - EKKO-EKGRP

ELSE.

l_po_header-purch_org = '1000'. " Purch. Org - EKKO-EKORG

l_po_header-pur_group = '001'. " Purch Group - EKKO-EKGRP

ENDIF.

l_po_header-currency_iso = 'USD'. " Currency Default field for Enjoy

l_po_header-ref_1 = itab-line+1(9).

*L_PO_HEADER-DOC_CAT = 'F'. " Account Assign Cat EKPO-KNTTP

*_PO_HEADER-CREATED_BY = SY-UNAME.

CLEAR : l_po_headerx.

l_po_headerx-po_number = 'X'.

l_po_headerx-comp_code = 'X'." Company Code

l_po_headerx-doc_type = 'X'. " Order Typr BSART

l_po_headerx-vendor = 'X'. "Vendor - EKKO-LIFNR

l_po_headerx-purch_org = 'X'. " Purch. Org - EKKO-EKORG

l_po_headerx-pur_group = 'X'. " Purch Group - EKKO-EKGRP

l_po_headerx-currency_iso = 'X'. " Currency Default field for Enjoy

l_po_headerx-ref_1 = 'X'.

ENDFORM. " APPEND_HEADER

&----


*& Form APPEND_ITEM

&----


  • Material Number and Item print

----


  • --> p1 text

  • <-- p2 text

----


FORM append_item .

  • PO Line Items

l_item = l_item + 10.

t_po_items-po_item = l_item.

*T_PO_ITEMS-PO_ITEM = '00010'." Line Item No - EKPO-EBELP

*T_PO_ITEMS-SHORT_TEXT = 'KSR TEXT'." Line Item TEXT

CONCATENATE '00000000' itab-line+32(10) INTO t_po_items-material.

*T_PO_ITEMS-MATERIAL = '000000000000000043'. " Material No - EKPO-EMATN

CONCATENATE '00000000' itab-line+32(10) INTO t_po_items-ematerial.

t_po_items-plant = '2001'. " Plant - EKPO-WERKS

t_po_items-quantity = '1.000'.

t_po_items-net_price = '10.00'. " EKPO-NETPR

t_po_items-price_unit = '10 '.

*T_PO_ITEMS-TAX_CODE = 'A2'.

IF itab-line+0(4) EQ 'K034'.

t_po_items-acctasscat = 'R'.

t_po_items-plant = '1001'.

t_po_account-po_item = l_item.

t_po_account-profit_ctr = 'BR034'.

t_po_account-gl_account = '0000135075'.

  • T_PO_ACCOUNT-CO_AREA = '1000'.

APPEND t_po_account.

CLEAR t_po_account.

t_po_accountx-po_item = l_item.

t_po_accountx-profit_ctr = 'X'.

t_po_accountx-gl_account = 'X'.

  • T_PO_ACCOUNTX-CO_AREA = 'X'.

APPEND t_po_accountx.

CLEAR t_po_accountx.

ENDIF.

APPEND t_po_items.

CLEAR t_po_items.

t_po_itemsx-po_item = l_item.

t_po_itemsx-po_itemx = 'X'.

t_po_itemsx-acctasscat = 'X'.

t_po_itemsx-material = 'X'.

t_po_itemsx-ematerial = 'X'.

t_po_itemsx-plant = 'X'.

t_po_itemsx-quantity = 'X'.

t_po_itemsx-net_price = 'X'.

t_po_itemsx-price_unit = 'X'.

*T_PO_ITEMSX-TAX_CODE = 'X'.

APPEND t_po_itemsx.

CLEAR t_po_itemsx.

      • Second Line Item

ENDFORM. " APPEND_ITEM

&----


*& Form REFRESH_TABLE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM refresh_table .

REFRESH : t_po_items, t_po_itemsx.

CLEAR l_item.

ENDFORM. " REFRESH_TABLE

&----


*& Form append_error

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM append_error .

MOVE : sy-datum TO zerror-zdate,

sy-uzeit TO zerror-ztime,

itab+3(5) TO zerror-document_no,

t_return-message TO zerror-message.

lcounter = lcounter + 1.

zerror-counter = lcounter .

zerror-rec_type = itab-line(1).

MODIFY zerror. CLEAR zerror.

COMMIT WORK.

ENDFORM. " append_error

Also please check out the link below it will be helpful to you

http://web.mit.edu/sapr3/windocs/bpors03m.htm

http://www.finance.utoronto.ca/Page641.aspx

*********please reward points if the information is helpful to you********

Former Member
0 Kudos

Please compare the screen number in recording to ur actual number of screen in me21n.It might cause problem.

So if you find any difference then try to put comment like.

*perform bdc_dynpro using 'SAPMF02D' '7100'.

Former Member
0 Kudos

Hi

You can fill that field INCOTERMS and see.

Still it is giving that error or not.

Since it says that some mandatory field is not filled with data this error is coming, fill that field and record the bdc.

Better to use BAPI_PO_CREATE (ME21) or BAPI_PO_CREATE1 (for ME21N) BAPI for PO upload.

<b>Reward points for useful Answers</b>

Regards

Anji

0 Kudos

Hi anil,

thnks for the reply. well I tried that also, actually that message is coming as soon as i go on that screen. I mean before filling out the value its giving that message, so can that problem be resolved.

Thanks

Former Member
0 Kudos

Hi,

ME22N will not work on the Background, you need to use BAPI_PO_CREATE1 to create the Purchase order, anyways, BAPI is better than a BDC program.

Regards

Sudheer

Former Member
0 Kudos

Hi ,

The incoterm is in VBKD table, so if it's only in the record with position 000000, it means the incoterms is header data, if a item has a different one you should find a record of that item in VBKD.

REPORT ZTEST_BAPI .

*- BAPI related declarations

DATA : g_pohdr TYPE bapimepoheader,

g_pohdrx TYPE bapimepoheaderx,

gt_poitem TYPE TABLE OF bapimepoitem,

gt_poitemx TYPE TABLE OF bapimepoitemx,

gt_posched TYPE TABLE OF bapimeposchedule,

gt_poschedx TYPE TABLE OF bapimeposchedulx,

gt_poacct TYPE TABLE OF bapimepoaccount,

gt_poacctx TYPE TABLE OF bapimepoaccountx,

gt_poservice TYPE TABLE OF bapiesllc,

gt_posrvacc TYPE TABLE OF bapiesklc,

gt_return TYPE TABLE OF bapiret2.

perform prepare_header.

PERFORM prepare_items.

PERFORM prepare_schedule.

perform create_po.

&----


*& Form prepare_header

&----


  • Set up header structure

----


FORM prepare_header.

g_pohdr-comp_code = '2000'.

g_pohdrx-comp_code = 'X'.

  • set up doc type

g_pohdr-doc_type = 'NB'.

g_pohdrx-doc_type = 'X'.

g_pohdr-vendor = '0008000330'.

g_pohdrx-vendor = 'X'.

g_pohdr-langu = sy-langu.

g_pohdrx-langu = 'X'.

g_pohdr-purch_org = 'BA01'.

g_pohdrx-purch_org = 'X'.

g_pohdr-pur_group = '800'.

g_pohdrx-pur_group = 'X'.

g_pohdr-currency = 'USD'.

g_pohdrx-currency = 'X'.

ENDFORM. " prepare_header

&----


*& Form prepare_items

&----


  • Set up item values

----


FORM prepare_items.

DATA : ls_poitem TYPE bapimepoitem,

ls_poitemx TYPE bapimepoitemx.

ls_poitem-po_item = '00010'.

ls_poitemx-po_item = '00010'.

ls_poitemx-po_itemx = 'X'.

ls_poitem-short_text = 'ABSORBER,SHOCK:PALLETIZER'.

ls_poitemx-short_text = 'X'.

ls_poitem-material = '000000000001070062'.

ls_poitemx-material = 'X'.

ls_poitem-vend_mat = 'xyz'.

ls_poitemx-vend_mat = 'X'.

ls_poitem-quantity = '100'.

ls_poitemx-quantity = 'X'.

ls_poitem-po_unit = 'EA'.

ls_poitemx-po_unit = 'X'.

ls_poitem-po_unit_iso = 'EA'.

ls_poitemx-po_unit_iso = 'X'.

ls_poitem-net_price = '6.32'.

ls_poitemx-net_price = 'X'.

ls_poitem-price_unit = '1'.

ls_poitemx-price_unit = 'X'.

ls_poitem-item_cat = 'D'.

ls_poitemx-item_cat = 'X'.

ls_poitem-plant = '1575'.

ls_poitemx-plant = 'X'.

ls_poitem-ACCTASSCAT = 'K'.

ls_poitemx-ACCTASSCAT = 'X'.

  • ls_poitem-acctasscat = <fs_req>-knttp.

  • ls_poitemx-acctasscat = 'X'.

*

  • ls_poitem-distrib = <fs_req>-vrtkz.

  • ls_poitemx-distrib = 'X'.

*

  • ls_poitem-part_inv = <fs_req>-twrkz.

  • ls_poitemx-part_inv = 'X'.

*

  • ls_poitem-gr_ind = <fs_req>-wepos.

  • ls_poitemx-gr_ind = 'X'.

*

  • ls_poitem-gr_non_val = <fs_req>-weunb.

  • ls_poitemx-gr_non_val = 'X'.

*

  • ls_poitem-ir_ind = <fs_req>-repos.

  • ls_poitemx-ir_ind = 'X'.

  • ls_poitem-agreement = <fs_req>-konnr.

  • ls_poitemx-agreement = 'X'.

*

  • ls_poitem-agmt_item = <fs_req>-ktpnr.

  • ls_poitemx-agmt_item = 'X'.

*

  • ls_poitem-preq_no = <fs_req>-banfn.

  • ls_poitemx-preq_no = 'X'.

*

  • ls_poitem-preq_item = <fs_req>-bnfpo.

  • ls_poitemx-preq_item = 'X'.

*

  • ls_poitem-preq_name = <fs_req>-afnam.

  • ls_poitemx-preq_name = 'X'.

*

  • ls_poitem-pckg_no = <fs_req>-packno.

  • ls_poitemx-pckg_no = 'X'.

APPEND : ls_poitem TO gt_poitem,

ls_poitemx TO gt_poitemx.

ENDFORM. " prepare_items

&----


*& Form prepare_schedule

&----


  • Schedule data

----


FORM prepare_schedule.

DATA : ls_posched TYPE bapimeposchedule,

ls_poschedx TYPE bapimeposchedulx.

ls_poschedx-po_item = '00010'.

ls_posched-po_item = '00010'.

ls_poschedx-po_itemx = 'X'.

ls_posched-delivery_date = '10/31/2005'.

ls_poschedx-delivery_date = 'X'.

ls_posched-quantity = '100'.

ls_poschedx-quantity = 'X'.

  • ls_posched-preq_no = <fs_req>-banfn.

  • ls_poschedx-preq_no = 'X'.

*

  • ls_posched-preq_item = <fs_req>-bnfpo.

  • ls_poschedx-preq_item = 'X'.

APPEND : ls_posched TO gt_posched,

ls_poschedx TO gt_poschedx.

ENDFORM. " prepare_schedule

&----


*& Form create_po

&----


  • Create PO with ref to the req

----


FORM create_po.

DATA : lt_return TYPE TABLE OF bapiret2,

l_ponum TYPE banfn.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = g_pohdr

poheaderx = g_pohdrx

  • testrun = 'X'

IMPORTING

exppurchaseorder = l_ponum

TABLES

return = lt_return

poitem = gt_poitem

poitemx = gt_poitemx

poschedule = gt_posched

poschedulex = gt_poschedx

poaccount = gt_poacct

poaccountx = gt_poacctx

poservices = gt_poservice

posrvaccessvalues = gt_posrvacc.

APPEND LINES OF lt_return TO gt_return.

IF NOT l_ponum IS INITIAL.

MESSAGE s398(00) WITH 'Purchase document ' l_ponum

' successfully created'.

ENDIF.

ENDFORM. " create_po

<b>Reward points</b>

Regards