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: 

BAPI_PO_Create1

Former Member
0 Kudos
101

Hi all,

I wana pass set of items i.e internal table into bapi_po_create1, but i am asked to use refresh in a loop pass, if i refresh the table how can i append the entries. if i dont refresh it says Exception FAILURE.

can any1 tell me how do i do it.

Thanks n Regards,

santosh kotra.

11 REPLIES 11

Former Member
0 Kudos
71

HI Santosh

If the internal table contains only details of one PO, you need not REFRESH the internal tables after each loop pass.

But incase the internal table holds data of multiple PO's, then For each new PO you have to do the REFRESH and CLEARING.

Kind Regards

Eswar

0 Kudos
71

hi eshwar,

this is how i wana do it. but if i do this its throwing failure exeception.

now where do i refresh it.

loop at i_inputxt.

concatenate i_inputxt-posnr(4) '0' into v_posnr.

item-po_item = v_posnr.

item-plant = 'PD01'.

  • item-stge_loc = i_inputxt-lgort.

item-material = i_inputxt-matnr.

item-matl_group = i_inputxt-matkl.

item-quantity = i_inputxt-asqty.

item-preq_no = i_inputxt-ebeln.

item-preq_item = v_posnr.

item-trackingno = i_inputxt-cntno.

  • item-preq_item = i_input-posnr.

  • item-net_price = item-price_unit * item-quantity.

append item.

clear item.

endloop.

Thanks a lot.

0 Kudos
71

Hi Santosh

Can you tell me if you are trying to create one PO at a time???

Also, would you mind posting whole code. I guess that can give some idea and much better scope in advicing a better solution...

Kind Regards

Eswar

0 Kudos
71

hi eshwar,

this is the complete code. plz help me.

tables: mara,

lfa1,

eina,

eine,

eban,

zdrgsah, zdrgsap,

t100.

*Internal Table to get the input Data

data: begin of i_input occurs 0,

matnr like ekpo-matnr,

asqty like ekpo-menge,

ebeln like ekpo-ebeln,

posnr like zdrgsap-posnr,

invno like zdrgsap-invno,

invdt like zdrgsah-invdt,

netpr like zdrgsap-netpr,

cntno like zdrgsap-cntno,

shcnm like zdrgsah-shcnm,

werks like ekpo-werks,

lgort like ekpo-lgort,

matkl like ekpo-matkl,

end of i_input.

data: begin of i_error occurs 0,

matnr like mara-matnr,

remark(255) type c,

end of i_error.

data: i_mara type mara occurs 0 with header line,

i_eina like eina occurs 0 with header line,

i_eine like eine occurs 0 with header line.

*Data declaration.

data: v_file type string, " Variable for uploading file

v_item(5) type c, " Line item number

v_itno(2) type c,

p_wkurs like zdrgkurs-wkurs,

v_matnr(20) type c,

v_menge(20) type c,

v_banfn(20) type c,

v_bnfpo(20) type c,

v_bednr(20) type c,

p_lifnr like lfa1-lifnr,

v_flag,

p_lifnrtxt(10),

p_wkurstxt(9),

p_bsartxt(4).

.

data: begin of i_inputxt occurs 0,

matnr(18) ,

asqty(13) ,

ebeln(10) ,

posnr(6) ,

invno(10) ,

invdt(8) ,

netpr(11) ,

cntno(11) ,

shcnm(10) ,

werks(4) ,

lgort(4) ,

matkl(9) ,

end of i_inputxt.

  • Constants

constants : c_pd01 like eine-werks value 'PD01',

c_x value 'X'.

data : v_posnr like i_inputxt-posnr.

*Structures to hold PO header data

data : header like bapimepoheader ,

headerx like bapimepoheaderx .

data : cheader like bapimepocondheader occurs 0 with header line,

cheaderx like bapimepocondheaderx occurs 0 with header line.

*data : cheaderx like bapimepocondheaderx.

*data : begin of cheaderx occurs 0,

  • cond_type like bapimepocondheaderx-cond_type,

  • end of cheaderx.

*Internal Tables to hold PO ITEM DATA

data : item like bapimepoitem occurs 0 with header line,

itemx like bapimepoitemx occurs 0 with header line,

*Internal table to hold messages from BAPI call

return like bapiret2 occurs 0 with header line.

data : w_header(40) value 'PO Header'.

data : ws_langu like sy-langu.

*text-001 = 'PO Header' - define as text element

data : v_company like header-comp_code value 'SBA' ,

v_doctyp like header-doc_type value 'ZSEA' ,

v_cdate like header-creat_date,

v_vendor like header-vendor ,

v_pur_org like header-purch_org value 'SBAP' ,

v_pur_grp like header-pur_group value 'PG1' .

*Selection Screen Declarations

selection-screen begin of block b1 with frame title text-010.

parameters: p_invno like zdrgsah-invno obligatory,

p_bsart like ekko-bsart.

selection-screen end of block b1.

*selection-screen begin of block b2 with frame title text-002.

*parameters : item_num like item-po_item default '00010',

  • material like mara-matnr default '0011442062' ,

  • plant like item-plant default 'PD01' ,

  • quantity like item-quantity default 100.

*selection-screen end of block b2.

&----


start-of-selection.

&----


*DATA POPULATION

&----


ws_langu = sy-langu. "Language variable

  • To Upload the data into Internal table.

perform f_upload_data.

  • To Validate the input data.

perform f_check_data.

  • if i_error[] is initial.

  • To process the data file

  • perform f_process_session.

  • elseif not i_error[] is initial.

  • To display the error message

  • perform f_display_error.

perform bapi_call_data.

  • endif.

end-of-selection.

&----


*Output the messages returned from BAPI call

&----


loop at return.

write / return-message.

endloop.

&----


*& Form f_upload_data

&----


form f_upload_data .

select matwa as matnr asqty ebeln posnr b~invno invdt netpr cntno

shcnm into table i_input

from zdrgsah as a join zdrgsap as b on

a~invno = b~invno

where b~invno eq p_invno.

loop at i_input.

select single * from eban

where banfn eq i_input-ebeln

and bnfpo eq i_input-posnr.

if sy-subrc eq 0.

move eban-werks to i_input-werks.

move eban-lgort to i_input-lgort.

move eban-matkl to i_input-matkl.

modify i_input.

clear i_input.

endif.

endloop.

endform. " f_upload_data

&----


*& Form f_check_data

&----


form f_check_data .

if not i_input[] is initial.

select * from mara

into table i_mara

for all entries in i_input

where matnr eq i_input-matnr.

endif.

if i_mara[] is initial.

message e000(zcnc) with text-001.

endif.

read table i_input index 1.

if sy-subrc eq 0.

select single lifnr into p_lifnr from zdrgsup

where shcnm = i_input-shcnm.

if sy-subrc <> 0.

message e000(zcnc) with text-002.

endif.

endif.

select single wkurs into p_wkurs from zdrgkurs

where invno = p_invno.

if sy-subrc ne 0.

message e000(zcnc) with text-s11.

endif.

  • call function 'CONVERSION_EXIT_ALPHA_OUTPUT'

  • exporting

  • input = p_lifnr

  • importing

  • output = p_lifnr.

p_lifnrtxt = p_lifnr.

p_wkurstxt = p_wkurs.

p_bsartxt = p_bsart.

loop at i_input.

move-corresponding i_input to i_inputxt.

append i_inputxt.

endloop.

endform. "f_check_data

&----


*& Form bapi_call_data

&----


  • text

----


form bapi_call_data.

*POPULATE HEADER DATA FOR PO

v_cdate = sy-datum.

header-comp_code = v_company .

header-doc_type = v_doctyp .

header-creat_date = v_cdate .

header-vendor = p_lifnr .

header-langu = ws_langu .

header-quotation = p_invno.

header-exch_rate = p_wkurs.

header-ex_rate_fx = 'X'.

header-purch_org = v_pur_org .

header-pur_group = v_pur_grp .

header-doc_date = sy-datum.

&----


*POPULATE HEADER FLAG.

&----


headerx-comp_code = c_x.

headerx-doc_type = c_x.

headerx-creat_date = c_x.

headerx-vendor = c_x.

headerx-langu = c_x.

headerx-quotation = c_x.

headerx-exch_rate = c_x.

headerx-ex_rate_fx = c_x.

headerx-purch_org = c_x.

headerx-pur_group = c_x.

headerx-doc_date = c_x.

&----


*POPULATE HEADER DATA.CONDITIONS

&----


cheader-cond_type = 'ZCA1'.

append cheader.

cheader-cond_type = 'ZFA1'.

append cheader.

cheader-cond_type = 'ZINC'.

append cheader.

cheader-cond_type = 'ZIV1'.

append cheader.

cheader-cond_type = 'ZOT1'.

append cheader.

&----


*POPULATE HEADER CONDITION FLAG.

&----


cheaderx-cond_type = c_x.

append cheaderx.

  • cheaderx-cond_type = c_x.

  • append cheaderx.

  • cheaderx-cond_type = c_x.

  • append cheaderx.

  • cheaderx-cond_type = c_x.

  • append cheaderx.

  • cheaderx-cond_type = c_x.

  • append cheaderx.

&----


*POPULATE ITEM DATA.

&----


  • perform bdc_field using v_bednr i_input-cntno.

  • item-price_unit = '100'.

  • itemx-net_price = c_x.

  • append itemx.

  • clear itemx.

  • endloop.

loop at i_inputxt.

concatenate i_inputxt-posnr(4) '0' into v_posnr.

item-po_item = v_posnr.

item-plant = 'PD01'.

  • item-stge_loc = i_inputxt-lgort.

item-material = i_inputxt-matnr.

item-matl_group = i_inputxt-matkl.

item-quantity = i_inputxt-asqty.

item-preq_no = i_inputxt-ebeln.

item-preq_item = v_posnr.

item-trackingno = i_inputxt-cntno.

  • item-preq_item = i_input-posnr.

  • item-net_price = item-price_unit * item-quantity.

append item.

endloop.

&----


*POPULATE ITEM FLAG TABLE

**&----


*

concatenate i_inputxt-posnr(4) '0' into v_posnr.

itemx-po_item = v_posnr.

itemx-po_itemx = c_x.

itemx-material = c_x.

itemx-plant = c_x .

  • itemx-stge_loc = c_x .

itemx-quantity = c_x .

itemx-stge_loc = c_x .

itemx-tax_code = c_x .

itemx-item_cat = c_x .

item-preq_no = c_x.

item-preq_item = c_x.

itemx-acctasscat = c_x .

append itemx.

&----


*BAPI CALL

&----


call function 'BAPI_PO_CREATE1'

exporting

poheader = header

poheaderx = headerx

  • POADDRVENDOR =

  • TESTRUN =

  • IMPORTING

  • EXPPURCHASEORDER =

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

tables

  • pocondheader = cheader

  • pocondheaderx = cheaderx

return = return

poitem = item

poitemx = itemx.

&----


*Confirm the document creation by calling database COMMIT

&----


call function 'BAPI_TRANSACTION_COMMIT'

exporting

wait = 'X'.

  • IMPORTING

  • RETURN =

  • refresh item.

  • refresh itemx.

  • endloop.

endform. "bapi_call_data

*

*if sy-subrc = 0.

  • loop at return.

  • write / return-message.

  • endloop.

*endif

thanks,

santosh.

.

0 Kudos
71

Hi Santosh

From your code, i understand that every time the program is executed only one PO has to be created:

Have made few modifications, please check:

TABLES: MARA,
LFA1,
EINA,
EINE,
EBAN,
ZDRGSAH, ZDRGSAP,
T100.

*Internal Table to get the input Data
DATA: BEGIN OF I_INPUT OCCURS 0,
MATNR LIKE EKPO-MATNR,
ASQTY LIKE EKPO-MENGE,
EBELN LIKE EKPO-EBELN,
POSNR LIKE ZDRGSAP-POSNR,
INVNO LIKE ZDRGSAP-INVNO,
INVDT LIKE ZDRGSAH-INVDT,
NETPR LIKE ZDRGSAP-NETPR,
CNTNO LIKE ZDRGSAP-CNTNO,
SHCNM LIKE ZDRGSAH-SHCNM,
WERKS LIKE EKPO-WERKS,
LGORT LIKE EKPO-LGORT,
MATKL LIKE EKPO-MATKL,
END OF I_INPUT.

DATA: BEGIN OF I_ERROR OCCURS 0,
MATNR LIKE MARA-MATNR,
REMARK(255) TYPE C,
END OF I_ERROR.

DATA: I_MARA TYPE MARA OCCURS 0 WITH HEADER LINE,
I_EINA LIKE EINA OCCURS 0 WITH HEADER LINE,
I_EINE LIKE EINE OCCURS 0 WITH HEADER LINE.

*Data declaration.
DATA: V_FILE TYPE STRING, " Variable for uploading file
V_ITEM(5) TYPE C, " Line item number
V_ITNO(2) TYPE C,
P_WKURS LIKE ZDRGKURS-WKURS,
V_MATNR(20) TYPE C,
V_MENGE(20) TYPE C,
V_BANFN(20) TYPE C,
V_BNFPO(20) TYPE C,
V_BEDNR(20) TYPE C,
P_LIFNR LIKE LFA1-LIFNR,
V_FLAG,
P_LIFNRTXT(10),
P_WKURSTXT(9),
P_BSARTXT(4).
.

DATA: BEGIN OF I_INPUTXT OCCURS 0,
MATNR(18) ,
ASQTY(13) ,
EBELN(10) ,
POSNR(6) ,
INVNO(10) ,
INVDT(8) ,
NETPR(11) ,
CNTNO(11) ,
SHCNM(10) ,
WERKS(4) ,
LGORT(4) ,
MATKL(9) ,
END OF I_INPUTXT.


* Constants
CONSTANTS : C_PD01 LIKE EINE-WERKS VALUE 'PD01',
C_X VALUE 'X'.

DATA : V_POSNR LIKE I_INPUTXT-POSNR.

*Structures to hold PO header data
DATA : HEADER LIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .

DATA : CHEADER LIKE BAPIMEPOCONDHEADER OCCURS 0 WITH HEADER LINE,
CHEADERX LIKE BAPIMEPOCONDHEADERX OCCURS 0 WITH HEADER LINE.

*data : cheaderx like bapimepocondheaderx.
*data : begin of cheaderx occurs 0,
* cond_type like bapimepocondheaderx-cond_type,
* end of cheaderx.


*Internal Tables to hold PO ITEM DATA
DATA : ITEM LIKE BAPIMEPOITEM OCCURS 0 WITH HEADER LINE,
ITEMX LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,

*Internal table to hold messages from BAPI call
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA : W_HEADER(40) VALUE 'PO Header'.
DATA : WS_LANGU LIKE SY-LANGU.

*text-001 = 'PO Header' - define as text element

DATA : V_COMPANY LIKE HEADER-COMP_CODE VALUE 'SBA' ,
V_DOCTYP LIKE HEADER-DOC_TYPE VALUE 'ZSEA' ,
V_CDATE LIKE HEADER-CREAT_DATE,
V_VENDOR LIKE HEADER-VENDOR ,
V_PUR_ORG LIKE HEADER-PURCH_ORG VALUE 'SBAP' ,
V_PUR_GRP LIKE HEADER-PUR_GROUP VALUE 'PG1' .


*Selection Screen Declarations
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
PARAMETERS: P_INVNO LIKE ZDRGSAH-INVNO OBLIGATORY,
P_BSART LIKE EKKO-BSART.
SELECTION-SCREEN END OF BLOCK B1.

*selection-screen begin of block b2 with frame title text-002.
*parameters : item_num like item-po_item default '00010',
* material like mara-matnr default '0011442062' ,
* plant like item-plant default 'PD01' ,
* quantity like item-quantity default 100.
*selection-screen end of block b2.



*&---------------------------------------------------------------------*
START-OF-SELECTION.
*&---------------------------------------------------------------------*
*DATA POPULATION
*&---------------------------------------------------------------------*
  WS_LANGU = SY-LANGU. "Language variable

* To Upload the data into Internal table.
  PERFORM F_UPLOAD_DATA.

* To Validate the input data.
  PERFORM F_CHECK_DATA.

* if i_error[] is initial.
* To process the data file
* perform f_process_session.
* elseif not i_error[] is initial.
* To display the error message
* perform f_display_error.

  PERFORM BAPI_CALL_DATA.
* endif.

END-OF-SELECTION.

*&---------------------------------------------------------------------*
*Output the messages returned from BAPI call
*&---------------------------------------------------------------------*
  LOOP AT RETURN.
    WRITE / RETURN-MESSAGE.
  ENDLOOP.





*&---------------------------------------------------------------------*
*& Form f_upload_data
*&---------------------------------------------------------------------*
FORM F_UPLOAD_DATA .

  SELECT MATWA AS MATNR ASQTY EBELN POSNR B~INVNO INVDT NETPR CNTNO
  SHCNM INTO TABLE I_INPUT
  FROM ZDRGSAH AS A JOIN ZDRGSAP AS B ON
  A~INVNO = B~INVNO
  WHERE B~INVNO EQ P_INVNO.
  LOOP AT I_INPUT.
    SELECT SINGLE * FROM EBAN
    WHERE BANFN EQ I_INPUT-EBELN
    AND BNFPO EQ I_INPUT-POSNR.
    IF SY-SUBRC EQ 0.
      MOVE EBAN-WERKS TO I_INPUT-WERKS.
      MOVE EBAN-LGORT TO I_INPUT-LGORT.
      MOVE EBAN-MATKL TO I_INPUT-MATKL.
      MODIFY I_INPUT.
      CLEAR I_INPUT.
    ENDIF.
  ENDLOOP.



ENDFORM. " f_upload_data
*&---------------------------------------------------------------------*
*& Form f_check_data
*&---------------------------------------------------------------------*
FORM F_CHECK_DATA .
  IF NOT I_INPUT[] IS INITIAL.
    SELECT * FROM MARA
    INTO TABLE I_MARA
    FOR ALL ENTRIES IN I_INPUT
    WHERE MATNR EQ I_INPUT-MATNR.
  ENDIF.
  IF I_MARA[] IS INITIAL.
    MESSAGE E000(ZCNC) WITH TEXT-001.
  ENDIF.
  READ TABLE I_INPUT INDEX 1.
  IF SY-SUBRC EQ 0.
    SELECT SINGLE LIFNR INTO P_LIFNR FROM ZDRGSUP
    WHERE SHCNM = I_INPUT-SHCNM.
    IF SY-SUBRC <> 0.
      MESSAGE E000(ZCNC) WITH TEXT-002.
    ENDIF.

  ENDIF.
  SELECT SINGLE WKURS INTO P_WKURS FROM ZDRGKURS
  WHERE INVNO = P_INVNO.
  IF SY-SUBRC NE 0.
    MESSAGE E000(ZCNC) WITH TEXT-S11.
  ENDIF.

* call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
* exporting
* input = p_lifnr
* importing
* output = p_lifnr.

  P_LIFNRTXT = P_LIFNR.
  P_WKURSTXT = P_WKURS.
  P_BSARTXT = P_BSART.
  LOOP AT I_INPUT.
    MOVE-CORRESPONDING I_INPUT TO I_INPUTXT.
    APPEND I_INPUTXT.
  ENDLOOP.



ENDFORM. "f_check_data



*&--------------------------------------------------------------------*
*& Form bapi_call_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BAPI_CALL_DATA.

*POPULATE HEADER DATA FOR PO
  V_CDATE = SY-DATUM.
  HEADER-COMP_CODE = V_COMPANY .
  HEADER-DOC_TYPE = V_DOCTYP .
  HEADER-CREAT_DATE = V_CDATE .
  HEADER-VENDOR = P_LIFNR .
  HEADER-LANGU = WS_LANGU .
  HEADER-QUOTATION = P_INVNO.
  HEADER-EXCH_RATE = P_WKURS.
  HEADER-EX_RATE_FX = 'X'.
  HEADER-PURCH_ORG = V_PUR_ORG .
  HEADER-PUR_GROUP = V_PUR_GRP .
  HEADER-DOC_DATE = SY-DATUM.

*&---------------------------------------------------------------------*
*POPULATE HEADER FLAG.
*&---------------------------------------------------------------------*
  HEADERX-COMP_CODE = C_X.
  HEADERX-DOC_TYPE = C_X.
  HEADERX-CREAT_DATE = C_X.
  HEADERX-VENDOR = C_X.
  HEADERX-LANGU = C_X.
  HEADERX-QUOTATION = C_X.
  HEADERX-EXCH_RATE = C_X.
  HEADERX-EX_RATE_FX = C_X.
  HEADERX-PURCH_ORG = C_X.
  HEADERX-PUR_GROUP = C_X.
  HEADERX-DOC_DATE = C_X.


**&---------------------------------------------------------------------
**
**POPULATE HEADER DATA.CONDITIONS
**&---------------------------------------------------------------------
**
*  CHEADER-COND_TYPE = 'ZCA1'.
*  APPEND CHEADER.
*  CHEADER-COND_TYPE = 'ZFA1'.
*  APPEND CHEADER.
*  CHEADER-COND_TYPE = 'ZINC'.
*  APPEND CHEADER.
*  CHEADER-COND_TYPE = 'ZIV1'.
*  APPEND CHEADER.
*  CHEADER-COND_TYPE = 'ZOT1'.
*  APPEND CHEADER.
*
**&---------------------------------------------------------------------
**
**POPULATE HEADER CONDITION FLAG.
**&---------------------------------------------------------------------
**
*  CHEADERX-COND_TYPE = C_X.
*  APPEND CHEADERX.
** cheaderx-cond_type = c_x.
** append cheaderx.
** cheaderx-cond_type = c_x.
** append cheaderx.
** cheaderx-cond_type = c_x.
** append cheaderx.
** cheaderx-cond_type = c_x.
** append cheaderx.

*&---------------------------------------------------------------------*
*POPULATE ITEM DATA.
*&---------------------------------------------------------------------*

* perform bdc_field using v_bednr i_input-cntno.

* item-price_unit = '100'.



* itemx-net_price = c_x.
* append itemx.
* clear itemx.
* endloop.
  LOOP AT I_INPUTXT.

    CONCATENATE I_INPUTXT-POSNR(4) '0' INTO V_POSNR.
    ITEM-PO_ITEM = V_POSNR.
    ITEM-PLANT = 'PD01'.
* item-stge_loc = i_inputxt-lgort.
    ITEM-MATERIAL = I_INPUTXT-MATNR.
    ITEM-MATL_GROUP = I_INPUTXT-MATKL.
    ITEM-QUANTITY = I_INPUTXT-ASQTY.
    ITEM-PREQ_NO = I_INPUTXT-EBELN.
    ITEM-PREQ_ITEM = V_POSNR.
    ITEM-TRACKINGNO = I_INPUTXT-CNTNO.
* item-preq_item = i_input-posnr.
* item-net_price = item-price_unit * item-quantity.

    APPEND ITEM.

*&---------------------------------------------------------------------*
*POPULATE ITEM FLAG TABLE
**&---------------------------------------------------------------------
*


  CONCATENATE I_INPUTXT-POSNR(4) '0' INTO V_POSNR.
  ITEMX-PO_ITEM = V_POSNR.
  ITEMX-PO_ITEMX = C_X.
  ITEMX-MATERIAL = C_X.
  ITEMX-PLANT = C_X .
* itemx-stge_loc = c_x .
  ITEMX-QUANTITY = C_X .
  ITEMX-STGE_LOC = C_X .
  ITEMX-TAX_CODE = C_X .
  ITEMX-ITEM_CAT = C_X .
  ITEM-PREQ_NO = C_X.
  ITEM-PREQ_ITEM = C_X.
  ITEMX-ACCTASSCAT = C_X .

  APPEND ITEMX.
  
  ENDLOOP.

*&---------------------------------------------------------------------*
*BAPI CALL
*&---------------------------------------------------------------------*
  CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING
  POHEADER = HEADER
  POHEADERX = HEADERX
* POADDRVENDOR =
* TESTRUN =
* IMPORTING
* EXPPURCHASEORDER =
* EXPHEADER =
* EXPPOEXPIMPHEADER =
  TABLES
* pocondheader = cheader
* pocondheaderx = cheaderx
  RETURN = RETURN
  POITEM = ITEM
  POITEMX = ITEMX.


*&---------------------------------------------------------------------*
*Confirm the document creation by calling database COMMIT
*&---------------------------------------------------------------------*
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT = 'X'.
* IMPORTING
* RETURN =


* refresh item.
* refresh itemx.
* endloop.

ENDFORM. "bapi_call_data
*
*if sy-subrc = 0.
* loop at return.
* write / return-message.
* endloop.
*endif

Have commented the conditions part as the data you are just populating condition types with out any price and other requirements.

Also have brought the ITEMS FLAG population into the internal table as it has be one to one relation with the no. of records in ITEMS table.

Kind Regards

Eswar

0 Kudos
71

Hi Eshwar,

its throwing EXCEPTION FAILURE. should i refresh it now to avoid this excetion if so where to refresh.

Thanks,

Santosh.

0 Kudos
71

Hi eshwar,

Could you plz check the code, its throwing excetion failure again.....actually those conditions are not passed into bapi thts y i left it like tht. could u plz c dis.

Thanks,

santosh.

0 Kudos
71

HI Santosh

As you are using Internal number range for PO Number, i guess you have to import the PO Number.

Kind Regards

Eswar

0 Kudos
71

hi Eshwar,

if i take single value value its working but if i pass it in a loop its throwing tht error. Do u think its bcoz of number range??

0 Kudos
71

HI Santosh

Couldnt get, what you mean by SINGLE value??? Can you be more clear???

Kind Regards

Eswar

0 Kudos
71

i mean instead of set of items , if i giv only 1 item, im able to create PO but if i loop it its throwing exception FAILURE.

Thnaks,

Santosh Kotra.