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

Error in bapi as NO batch input

Former Member
0 Likes
519

Hi all,

im using BAPI_AGREEMENT_MAINTAIN to update short text in Certain contracts...

in a loop at it_ekpo BAPI gets succesfully updated for 1st and 3rd entries in it_ekpo.

but it is not getting executed sucessfully for 2nd entry.In it_return there is error as 'NO BATCH INPUT FOR some SCREEN.'

All required inputs for that Contract r provided in the BAPI.

but stil there is error

following is my code.

&----


*& Report ZSEMM_CONTRACT_TEXT_UPLOAD *

*& *

&----


*& *

*& *

&----


REPORT zsemm_contract_text_upload.

&----


*& Module Material Management *

&----


*& Objective : *

*& Program for maintenance of short text for contracts when material *

*& description changed in material master. *

*& *

*& *

*& Note *

*& *

*& *

*& Program : Update Tables(X) Download Data() *

*& Output Lists () *

*& *

*& Tech. Spec: SE_CR_0302_TS_Contract text upload.doc *

*& Date Created : 26/02/2008 *

*& Author : Amruta Sawant *

&----


  • Amendment History *

&----


  • Date Change By Change ID Reason

&----


----


  • TYPES *

----


TYPES : BEGIN OF ty_cdpos,

o_cl TYPE cdhdr-objectclas, " Object Class.

objectid TYPE cdhdr-objectid, " Object Id.

changenr TYPE cdhdr-changenr, " Change Number.

username TYPE cdhdr-username, " User Name.

udate TYPE cdhdr-udate, " User Date.

tcode TYPE cdhdr-tcode, " Transaction Code.

tabname TYPE cdpos-tabname, " Table Name.

tabkey TYPE cdpos-tabkey, " Table Key.

tabkey_new TYPE spras,

fname TYPE cdpos-fname, " Field Name.

value_new TYPE cdpos-value_new, " New Value.

value_old TYPE cdpos-value_old, " Old Value.

objectid_new TYPE matnr,

END OF ty_cdpos.

TYPES : BEGIN OF ty_cdhdr,

o_cl TYPE cdhdr-objectclas, " Object Class.

objectid TYPE cdhdr-objectid, " Object Id.

changenr TYPE cdhdr-changenr, " Change Number.

END OF ty_cdhdr.

TYPES : BEGIN OF ty_ekpo,

ebeln TYPE ekko-ebeln, " Purchasing Document Number.

ebelp TYPE ekpo-ebelp, " Purchasing Document Item Number.

spras TYPE ekko-spras, " Language Key.

matnr TYPE cdobjectv,

kdate TYPE ekko-kdate, " End Of Validity Period.

bstyp TYPE ekko-bstyp, " Purchasing Document Category.

waers TYPE ekko-waers, " Currency Key.

aedat TYPE ekpo-aedat,

END OF ty_ekpo.

----


  • DATA CONSTANTS BEGIN WITH C_ *

----


CONSTANTS : c_objectclas TYPE cdhdr-objectclas VALUE 'MATERIAL',

c_tabname TYPE cdpos-tabname VALUE 'DMAKT',

c_fname TYPE cdpos-fname VALUE 'MAKTX',

c_bstyp TYPE ekko-bstyp VALUE 'K',

c_x TYPE c VALUE 'X'.

----


  • INTERNAL TABLES BEGIN WITH IT_ *

----


DATA : it_cdpos TYPE STANDARD TABLE OF ty_cdpos,

it_cdnr TYPE STANDARD TABLE OF ty_cdhdr,

it_ekpo TYPE STANDARD TABLE OF ty_ekpo,

it_poitem TYPE STANDARD TABLE OF bapioaitem,

it_poitemx TYPE STANDARD TABLE OF bapioaitex,

it_return TYPE STANDARD TABLE OF bapiret2.

----


  • WORK AREA BEGIN WITH WA_ *

----


DATA : wa_cdpos TYPE ty_cdpos,

wa_cdnr TYPE ty_cdhdr,

wa_ekpo TYPE ty_ekpo,

wa_header TYPE bapioahead,

wa_headerx TYPE bapioaheax,

wa_poitem TYPE bapioaitem,

wa_poitemx TYPE bapioaitex.

----


  • VARIABLE DECLARATION BEGIN WITH W_ *

----


DATA : w_sydatum TYPE ekko-kdate.

----


  • SELECT-OPTIONS BEGIN WITH SO_ *

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : so_objcl FOR wa_cdnr-o_cl DEFAULT 'MATERIAL', " Object Class

so_uname FOR wa_cdpos-username, " User Name

so_udate FOR wa_cdpos-udate, " User Date

so_tcode FOR wa_cdpos-tcode DEFAULT 'MM02'. " Transaction Code

SELECTION-SCREEN END OF BLOCK b1.

----


  • START OF SELECTION

----


CLEAR it_cdnr.

  • Get object class (objectclas), object id (objectid), change no.(changenr) from table CDHDR.

SELECT objectclas objectid changenr

FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE it_cdnr

WHERE objectclas IN so_objcl

AND username IN so_uname

AND udate IN so_udate

AND tcode IN so_tcode.

CLEAR it_cdpos.

IF NOT it_cdnr IS INITIAL.

  • Get object class (objectclas), object id (objectid), change no.(changenr)

  • table name(tabnam), table key(tabkey), field name(fname), new value(value_new)

SELECT objectclas objectid changenr tabname tabkey fname value_new value_old

INTO CORRESPONDING FIELDS OF TABLE it_cdpos

FROM cdpos

FOR ALL ENTRIES IN it_cdnr

WHERE changenr = it_cdnr-changenr

AND objectclas = c_objectclas "MATERIAL

AND tabname = c_tabname "DMAKT

AND fname = c_fname. "MAKTX

IF sy-subrc = 0.

LOOP AT it_cdpos INTO wa_cdpos.

  • assign matnr and spras of type char18 and lang1 to variables

  • objectid_new and tabkey_new which are of type char90 and char70 resp.

wa_cdpos-objectid_new = wa_cdpos-objectid.

wa_cdpos-tabkey_new = wa_cdpos-tabkey.

MODIFY it_cdpos FROM wa_cdpos TRANSPORTING objectid_new tabkey_new.

ENDLOOP.

  • Get Contract value no (ebeln), Item no (ebelp), Language Key (spras), Currency Key (waers),

  • End of validity period (kdate), Document category type (bstyp), Material Number (matnr).

SELECT aebeln aspras awaers akdate abstyp bebelp bmatnr baedat

INTO CORRESPONDING FIELDS OF TABLE it_ekpo

FROM ekko AS a JOIN ekpo AS b ON aebeln = bebeln

FOR ALL ENTRIES IN it_cdpos

WHERE b~matnr = it_cdpos-objectid_new

AND a~spras = it_cdpos-tabkey_new

AND a~bstyp = c_bstyp.

ENDIF. "sy-subrc

CLEAR wa_cdpos.

LOOP AT it_cdpos INTO wa_cdpos.

IF NOT it_ekpo IS INITIAL.

CLEAR wa_ekpo.

LOOP AT it_ekpo INTO wa_ekpo WHERE matnr = wa_cdpos-objectid.

  • Assigning value to header

CLEAR wa_header.

wa_header-agmt_no = wa_ekpo-ebeln.

wa_header-doc_cat = wa_ekpo-bstyp. "c_bstyp.

wa_header-langu = wa_ekpo-spras.

wa_header-currency = wa_ekpo-waers.

CLEAR wa_headerx.

wa_headerx-agmt_no = c_x.

wa_headerx-doc_cat = c_x.

wa_headerx-langu = c_x.

wa_headerx-currency = c_x.

  • Appending itab which has to pass to BAPI.

CLEAR it_poitem.

wa_poitem-agrmt_item = wa_ekpo-ebelp.

wa_poitem-short_text = wa_cdpos-value_new.

APPEND wa_poitem TO it_poitem.

CLEAR it_poitemx.

wa_poitemx-agrmt_item = wa_ekpo-ebelp.

wa_poitemx-short_text = c_x.

APPEND wa_poitemx TO it_poitemx.

  • Call BAPI to to update the short text to table EKPO for the document type 'CONTRACTS'.

CALL FUNCTION 'BAPI_AGREEMENT_MAINTAIN'

EXPORTING

im_agreement_header = wa_header

im_agreement_header_x = wa_headerx

TABLES

ext_return = it_return

imt_agreement_items = it_poitem

imt_agreement_items_x = it_poitemx.

  • Call BAPI to commit the transaction.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '.

ENDLOOP.

ENDIF.

CLEAR : wa_cdnr.

ENDLOOP. " it_cdos

ENDIF.

----


  • END OF SELECTION

----


Please help me ...its urgent

Thanks in advance,

Amruta

2 REPLIES 2
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
459

Go to that 'some SCREEN' (in SE38 or SE80) and see what data is on it. Then add this data when you are calling BAPI. Some data might be required only under certain conditions, so you might need to experiment.

Read only

Former Member
0 Likes
459

it is purely a DATA issue.

You need to check the data which you are passing to BAPI...

It could be because of some configuration data missing or some customizing data missing or some required fields are not populated...