Skip to Content
author's profile photo Former Member
Former Member

error field is not getting populated into corresponding str. in Zrfc

hi,

In case of error in PO creation i am not getting all the data i nto correponding structure..

*data it_head type standard table of bapimepoheader.

DATA ls_head TYPE bapimepoheader.

DATA it_headx TYPE STANDARD TABLE OF bapimepoheaderx.

DATA ls_headx TYPE bapimepoheaderx.

data : it_temp_ekpo type zpo_item_60 occurs 0 with header line.

DATA it_item TYPE STANDARD TABLE OF bapimepoitem.

DATA ls_item TYPE bapimepoitem.

DATA it_itemx TYPE STANDARD TABLE OF bapimepoitemx.

DATA ls_itemx TYPE bapimepoitemx.

DATA it_sch TYPE STANDARD TABLE OF bapimeposchedule .

DATA ls_sch TYPE bapimeposchedule.

DATA it_schx TYPE STANDARD TABLE OF bapimeposchedulx.

DATA ls_schx TYPE bapimeposchedulx.

DATA it_poact TYPE STANDARD TABLE OF bapimepoaccount.

DATA ls_poact TYPE bapimepoaccount.

DATA it_poactx TYPE STANDARD TABLE OF bapimepoaccountx.

DATA ls_poactx TYPE bapimepoaccountx.

DATA it_cond TYPE STANDARD TABLE OF bapimepocond.

DATA ls_cond TYPE bapimepocond.

DATA it_adrc TYPE STANDARD TABLE OF bapimepoaddrdelivery.

DATA st_adrc TYPE bapimepoaddrdelivery.

DATA it_condx TYPE STANDARD TABLE OF bapimepocondx.

DATA ls_condx TYPE bapimepocondx.

DATA it_popart TYPE STANDARD TABLE OF bapiekkop.

DATA ls_popart TYPE bapiekkop.

data : ret2 type bapiret2 occurs 0 with header line.

DATA ls_ekko TYPE zpo_data_60.

DATA st_ekko TYPE zpo_data_60.

DATA ls_ekpo TYPE zpo_item_60.

DATA st_ekpo TYPE zpo_item_60.

DATA: ls_adrc TYPE zpo_adrc_60,

ls_ekkn TYPE zpo_ekkn_60,

ls_eket TYPE zpo_eket_60,

ls_ekbe TYPE zpo_ekbe_60,

w_purchaseorder type BAPIMEPOHEADER-PO_NUMBER.

LOOP AT lt_ekpo INTO st_ekpo.

ls_ekpo = st_ekpo.

AT NEW ebeln.

READ TABLE lt_ekko WITH KEY ebeln = ls_ekpo-ebeln.

IF sy-subrc = 0.

ls_head-comp_code = lt_ekko-bukrs.

ls_head-doc_type = lt_ekko-bsart.

ls_head-vendor = lt_ekko-lifnr.

ls_head-purch_org = lt_ekko-ekorg.

ls_head-pur_group = lt_ekko-ekgrp.

ls_head-pmnttrms = lt_ekko-zterm.

ls_head-exch_rate = lt_ekko-wkurs.

  • ls_head-incoterms1 = lt_ekko-inco1.

  • ls_head-incoterms2 = lt_ekko-inco2.

ls_head-currency = lt_ekko-waers.

ls_head-PO_NUMBER = lt_ekko-ebeln.

*append ls_head to it_head.

*Parameter: POHEADERX

ls_headx-comp_code = 'X' .

ls_headx-doc_type = 'X' .

ls_headx-vendor = 'X' .

ls_headx-purch_org = 'X'.

ls_headx-pur_group = 'X' .

ls_headx-pmnttrms = 'X'.

ls_headx-currency = 'X'.

ls_headx-exch_rate = 'X'.

  • ls_headx-incoterms1 = 'X'.

  • ls_headx-incoterms2 = 'X'.

ls_headx-currency = 'X'.

ls_headx-PO_NUMBER = 'X'.

*append ls_headx to it_headx.

ENDIF.

ENDAT.

ls_item-po_unit = ls_ekpo-meins.

ls_item-po_item = ls_ekpo-ebelp.

ls_item-material = ls_ekpo-matnr.

ls_item-price_unit = ls_ekpo-peinh.

ls_item-orderpr_un = ls_ekpo-bprme.

ls_item-net_price = ls_ekpo-netpr.

ls_item-matl_group = ls_ekpo-matkl.

  • ls_item-short_text = ls_ekpo-txz01.

ls_item-plant = ls_ekpo-werks.

ls_item-stge_loc = ls_ekpo-lgort.

ls_item-quantity = ls_ekpo-menge.

ls_item-acctasscat = ls_ekpo-knttp.

ls_item-gr_basediv = ls_ekpo-webre.

ls_item-vend_mat = ls_ekpo-idnlf.

ls_item-no_more_gr = ls_ekpo-elikz.

ls_item-final_inv = ls_ekpo-erekz.

ls_item-gr_ind = ls_ekpo-wepos.

ls_item-gr_non_val = ls_ekpo-weunb.

ls_item-conv_num1 = ls_ekpo-bpumz.

ls_item-conv_den1 = ls_ekpo-bpumn.

ls_item-ir_ind = ls_ekpo-repos.

ls_item-unlimited_dlv = ls_ekpo-uebtk.

ls_item-reminder1 = ls_ekpo-mahn1.

ls_item-reminder2 = ls_ekpo-mahn2.

ls_item-reminder3 = ls_ekpo-mahn3.

ls_item-vend_mat = ls_ekpo-idnlf.

ls_item-no_more_gr = ls_ekpo-elikz.

ls_item-final_inv = ls_ekpo-erekz.

ls_item-gr_ind = ls_ekpo-wepos.

append ls_ekpo to it_temp_ekpo.

*Parameter: POITEMX

ls_itemx-po_unit = 'X'.

ls_itemx-po_item = ls_ekpo-ebelp.

ls_itemx-material = 'X'.

ls_itemx-price_unit = 'X'.

ls_itemx-orderpr_un = 'X'.

ls_itemx-net_price = 'X'.

ls_itemx-matl_group = 'X'.

  • ls_itemx-short_text = 'X'.

ls_itemx-plant = 'X'.

ls_itemx-stge_loc = 'X'.

ls_itemx-quantity = 'X'.

ls_itemx-acctasscat = 'X'.

ls_itemx-gr_basediv = 'X'.

ls_itemx-vend_mat = 'X'.

ls_itemx-no_more_gr = 'X'.

ls_itemx-final_inv = 'X'.

ls_itemx-gr_ind = 'X'.

ls_itemx-gr_non_val = 'X'.

ls_itemx-conv_num1 = 'X'.

ls_itemx-conv_den1 = 'X'.

ls_itemx-ir_ind = 'X'.

ls_itemx-unlimited_dlv = 'X'.

ls_itemx-reminder1 = 'X'.

ls_itemx-reminder2 = 'X'.

ls_itemx-reminder3 = 'X'.

ls_itemx-vend_mat = 'X'.

ls_itemx-no_more_gr = 'X'.

ls_itemx-final_inv = 'X'.

ls_itemx-gr_ind = 'X'.

APPEND ls_itemx TO it_itemx.

APPEND ls_item TO it_item.

READ TABLE lt_eket INTO ls_eket WITH KEY ebeln = ls_ekpo-ebeln

ebelp = ls_ekpo-ebelp.

IF sy-subrc = 0.

*Parameter: POSCHEDULE

ls_sch-po_item = ls_ekpo-ebelp.

ls_sch-sched_line = LS_EKET-ETENR.

ls_sch-delivery_date = ls_eket-eindt.

ls_sch-quantity = ls_ekpo-menge .

APPEND ls_sch TO it_sch.

ENDIF.

*Parameter: POSCHEDULEX

ls_schx-po_item = ls_ekpo-ebelp.

ls_schx-sched_line = LS_EKET-ETENR.

ls_schx-po_itemx = 'X' .

ls_schx-sched_linex = 'X'.

ls_schx-delivery_date = 'X'.

ls_schx-quantity = 'X' .

APPEND ls_schx TO it_schx.

read table lt_ekkn into ls_ekkn with key ebeln = ls_ekpo-ebeln

ebelp = ls_ekpo-ebelp.

*Parameter: POACCOUNT

IF SY-SUBRC = 0.

ls_poact-po_item = ls_ekpo-ebelp.

ls_poact-serial_no = sy-tabix.

ls_poact-quantity = ls_ekpo-menge.

ls_poact-gl_account = ls_ekkn-sakto.

ls_poact-costcenter = ls_ekkn-KOSTL.

  • ls_poact-co_area = '1000'.

ls_poact-tax_code = ls_ekkn-mwskz.

APPEND ls_poact TO it_poact.

ENDIF.

*Parameter: POACCOUNTX

ls_poactx-po_item = 'X' .

ls_poactx-serial_no = sy-tabix .

ls_poactx-quantity = 'X' .

ls_poactx-gl_account = 'X' .

ls_poactx-costcenter = 'X' .

  • ls_poactx-co_area = 'X' .

ls_poactx-tax_code = 'X' .

APPEND ls_poactx TO it_poactx.

*Parameter: POCOND

ls_cond-itm_number = ls_ekpo-ebelp.

ls_cond-cond_st_no = '001' .

ls_cond-cond_type = 'PB00' .

ls_cond-cond_value = '79.900000000' .

ls_cond-currency = ls_ekko-waers.

ls_cond-currency_iso = 'USD'.

ls_cond-cond_unit = 'KG' .

ls_cond-cond_p_unt = '1' .

ls_cond-change_id = 'U' .

APPEND ls_cond TO it_cond.

*Parameter: POCONDX

ls_condx-itm_number = ls_ekpo-ebelp.

ls_condx-cond_st_no = '000' .

ls_condx-itm_numberx = 'X' .

ls_condx-cond_type = 'X' .

ls_condx-cond_value = 'X' .

ls_condx-currency = 'X' .

ls_condx-change_id = 'X' .

APPEND ls_condx TO it_condx.

*Parameter: POPARTNER,

  • ls_popart-partnerdesc = 'OA' .

  • ls_popart-langu = 'EN' .

  • ls_popart-buspartno = '0000001100' .

  • ls_popart-partnerdesc = 'GS' .

  • ls_popart-langu = 'EN' .

  • ls_popart-buspartno = '0000001200' .

  • ls_popart-partnerdesc = 'IP' .

  • ls_popart-langu = 'EN' .

  • ls_popart-buspartno = '0000001000'.

*

  • APPEND ls_popart TO it_popart.

*

  • Address data

READ TABLE lt_adrc INTO ls_adrc WITH KEY addrnumber = ls_ekko-adrnr.

IF sy-subrc = 0.

st_adrc-addr_no = ls_adrc-addrnumber.

st_adrc-name = ls_adrc-name1.

st_adrc-street = ls_adrc-street.

st_adrc-district = ls_adrc-city2.

st_adrc-postl_cod1 = ls_adrc-post_code1.

st_adrc-city = ls_adrc-city1.

st_adrc-country = ls_adrc-country.

st_adrc-region = ls_adrc-region.

APPEND st_adrc TO it_adrc.

ENDIF.

AT END OF ebeln.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

poheader = ls_head

poheaderx = ls_headx

  • POADDRVENDOR =

  • TESTRUN =

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO =

IMPORTING

EXPPURCHASEORDER = w_purchaseorder

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

return = ret2

poitem = it_item

poitemx = it_itemx

poaddrdelivery = it_adrc

poschedule = it_sch

poschedulex = it_schx

poaccount = it_poact

  • POACCOUNTPROFITSEGMENT =

poaccountx = it_poactx

  • POCONDHEADER =

  • POCONDHEADERX =

pocond = it_cond

pocondx = it_condx

  • POLIMITS =

  • POCONTRACTLIMITS =

  • POSERVICES =

  • POSRVACCESSVALUES =

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • popartner = it_popart

  • POCOMPONENTS =

  • POCOMPONENTSX =

  • POSHIPPING =

  • POSHIPPINGX =

  • POSHIPPINGEXP =

.

if w_purchaseorder is not initial.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

.

LOOP AT ret2 WHERE type = 'S'.

lt_success_po-ebeln = ret2-message_v2.

lt_success_po-type = ret2-type.

lt_success_po-message = ret2-message.

append lt_success_po.

clear : lt_success_po.

ENDLOOP.

else.

append lt_ekko to lt_ekko_error.

append it_temp_ekpo to lt_ekpo_error.

append ls_eket to lt_eket_error.

append ls_adrc to lt_adrc_error.

append ls_ekkn to lt_ekkn_error.

*loop at ret2 where type = 'E'.

*

**move-corresponding lt_ekko to lt_error_po.

**move-corresponding ls_ekpo to lt_error_po.

**move ret2-type to lt_error_po-type.

**move ret2-message to lt_error_po-message.

*append

**lt_error_po.

**clear :

**lt_error_po.

  • endloop.

endif.

CLEAR : ls_ekko,

st_ekko,

ls_ekpo,

st_ekpo,

ls_ekkn,

ls_ekbe,

ls_eket.

ENDAT.

ENDLOOP.

ENDFUNCTION.

Message was edited by:

ruban R

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Nov 20, 2007 at 07:56 PM

    You should use:

    READ TABLE lt_adrc INTO ls_adrc WITH KEY addrnumber = <b>ls_ekko-adrnr</b>.
    
    append [code]LS_ekko

    to lt_ekko_error.

    append it_temp_ekpo to lt_ekpo_error.

    append ls_eket to lt_eket_error.

    append ls_adrc to lt_adrc_error.

    append ls_ekkn to lt_ekkn_error.[/code]

    Debug your FM, you will understand what is going wrong.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 20, 2007 at 07:08 PM

    You must get all the messages into

    RET2

    table.

    You need to fill your ZRFC's RETURN table with the data from RET2 after the FM 'BAPI_PO_CREATE1' call. Because your BAPI is calling mulitple times and henceforth your RET2 is being refreshed and contains the last executed BAPI's return message.

    So,

    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
     ..... .. .
    
    EXCEPITON
    ...
    
    LOOP AT RET2.
      MOVE-CORRESPONDING RET2 TO IT_RETRUN.   " << This is the table which you need to pass back to ZRFC 
      APPEND IT_RETURN.
    ENDLOOP.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.