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

Bapi function is not processing

Hi experts,

i am getting problem when i am calling one bapi function module BAPI_GOODSMVT_CREATE.

In this function module one of the function module mb_post_goods_movement is not getting processed.

One more important thing is This program was working fine when we were using oracle 9i.

This problem started when we started using oracle 10g database.

This is my program which i am getting error.

REPORT z_consumption.

DATA: wa_goodsmvthdr LIKE bapi2017_gm_head_01,

wa_goodsmvt_code LIKE bapi2017_gm_code,

wa_goodsmvthdr_ret LIKE bapi2017_gm_head_ret.

DATA: it_return TYPE TABLE OF bapiret2,

wa_return TYPE bapiret2.

DATA: it_goodsmvt_item TYPE TABLE OF bapi2017_gm_item_create,

wa_item TYPE bapi2017_gm_item_create.

DATA: w_materialdocument LIKE bapi2017_gm_head_ret-mat_doc,

w_testrun LIKE bapi2017_gm_gen-testrun.

DATA: con_doc LIKE bapi2017_gm_head_ret-mat_doc.

DATA: BEGIN OF l_intern OCCURS 0.

INCLUDE STRUCTURE alsmex_tabline.

DATA: END OF l_intern.

DATA : l_index TYPE i.

TYPES: BEGIN OF itab1,

matnr LIKE mast-matnr,

quantity LIKE stpo-menge,

werks LIKE mast-werks,

lgort LIKE t320-lgort,

amount_lc LIKE bapi2017_gm_item_create-amount_lc,

END OF itab1.

DATA : itab TYPE STANDARD TABLE OF itab1 WITH HEADER LINE.

DATA : BEGIN OF itab_com OCCURS 0,

stlnr LIKE mast-stlnr,

idnrk LIKE stpo-idnrk,

menge LIKE stpo-menge,

meins LIKE stpo-meins,

  • VALUE TYPE STRING,

value TYPE p DECIMALS 2,

werks LIKE mast-werks,

lgort LIKE t320-lgort,

END OF itab_com.

DATA : z_stlnr LIKE mast-stlnr.

DATA : z_verpr LIKE mbew-verpr.

DATA : zumren LIKE marm-umren.

DATA: zumrez LIKE marm-umrez.

DATA : zconv LIKE stpo-menge.

DATA : amount_lc LIKE bapi2017_gm_item_create-amount_lc.

----


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

PARAMETERS : p_file TYPE rlgrap-filename LOWER CASE OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

file_name = p_file

EXCEPTIONS

mask_too_long = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

----


START-OF-SELECTION.

PERFORM upload_file TABLES itab

USING p_file.

CLEAR amount_lc.

LOOP AT itab.

************************Modification by Mr. Amit Dabas & Mr. Naresh Kumar ***************************

***********************Non Site Specific BOM****************************************************

SELECT SINGLE stlnr FROM mast INTO z_stlnr WHERE matnr = itab-matnr AND stlan = '3' and stlal = '01' and ( werks = '' OR werks = itab-werks ).

SELECT idnrk menge meins FROM stpo INTO CORRESPONDING FIELDS OF itab_com WHERE stlty = 'M' AND stlnr = z_stlnr.

SELECT SINGLE verpr FROM mbew INTO z_verpr WHERE matnr = itab_com-idnrk AND bwkey = itab-werks.

SELECT SINGLE umren FROM marm INTO zumren WHERE matnr = itab_com-idnrk AND meinh = itab_com-meins. " Modification

SELECT SINGLE umrez FROM marm INTO zumrez WHERE matnr = itab_com-idnrk AND meinh = itab_com-meins. " Modification

itab_com-stlnr = z_stlnr.

itab_com-menge = ( itab_com-menge * itab-quantity ).

  • modification

  • ZMENGE = ( ITAB_COM-MENGE / ZUMREN ).

zconv = zumrez / zumren.

itab_com-value = ( zconv * z_verpr * itab_com-menge ).

  • ITAB_COM-menge = ZMENGE.

  • ITAB_COM-VALUE = ( ITAB_COM-MENGE * Z_VERPR ).

****************************************************

CLEAR : z_verpr,zconv,zumren.

amount_lc = amount_lc + itab_com-value.

itab_com-werks = itab-werks.

itab_com-lgort = itab-lgort.

APPEND itab_com.

ENDSELECT.

itab-amount_lc = amount_lc.

MODIFY itab TRANSPORTING amount_lc.

CLEAR amount_lc.

ENDLOOP.

LOOP AT itab_com.

wa_item-material = itab_com-idnrk.

wa_item-plant = itab_com-werks.

wa_item-stge_loc = itab_com-lgort.

wa_item-move_type = 'ZR1'.

wa_item-entry_qnt = itab_com-menge.

wa_item-base_uom = itab_com-meins. " Modification

APPEND wa_item TO it_goodsmvt_item.

ENDLOOP.

wa_goodsmvthdr-pstng_date = sy-datum.

wa_goodsmvthdr-doc_date = sy-datum.

wa_goodsmvthdr-header_txt = 'RESTAURANT CONSUMPTION'.

wa_goodsmvt_code = '03'.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE'

EXPORTING

goodsmvt_header = wa_goodsmvthdr

goodsmvt_code = wa_goodsmvt_code

testrun = w_testrun

IMPORTING

goodsmvt_headret = wa_goodsmvthdr_ret

materialdocument = w_materialdocument

  • MATDOCUMENTYEAR =

TABLES

goodsmvt_item = it_goodsmvt_item

  • GOODSMVT_SERIALNUMBER =

return = it_return

.

IF NOT w_materialdocument IS INITIAL.

con_doc = w_materialdocument.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE'

EXPORTING

wait = 'X'

IMPORTING

return = wa_return.

IF sy-subrc = 0.

  • WRITE: / 'Goods Recieve document saved' , w_materialdocument.

*************************************************************************

wa_goodsmvthdr-pstng_date = sy-datum.

wa_goodsmvthdr-doc_date = sy-datum.

wa_goodsmvthdr-header_txt = 'Receipt of Semifinished'.

wa_goodsmvt_code = '05'.

REFRESH it_goodsmvt_item[].

CLEAR wa_item.

LOOP AT itab.

wa_item-material = itab-matnr.

wa_item-plant = itab-werks.

wa_item-stge_loc = itab-lgort.

wa_item-move_type = 'YR1'.

wa_item-entry_qnt = itab-quantity.

wa_item-amount_lc = itab-amount_lc.

APPEND wa_item TO it_goodsmvt_item.

ENDLOOP.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE'

EXPORTING

goodsmvt_header = wa_goodsmvthdr

goodsmvt_code = wa_goodsmvt_code

testrun = w_testrun

IMPORTING

goodsmvt_headret = wa_goodsmvthdr_ret

materialdocument = w_materialdocument

  • MATDOCUMENTYEAR =

TABLES

goodsmvt_item = it_goodsmvt_item

  • GOODSMVT_SERIALNUMBER =

return = it_return.

IF NOT w_materialdocument IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE'

EXPORTING

wait = 'X'

IMPORTING

return = wa_return.

IF sy-subrc = 0.

WRITE: / 'Raw Material Consumed and document saved - ' , con_doc.

SKIP.

WRITE: / 'Semi-finished Goods Posted and document saved - ' , w_materialdocument.

ENDIF.

ELSE.

WRITE 'Goods Post has errors ..' .

LOOP AT it_return INTO wa_return.

WRITE: / wa_return-message.

ENDLOOP.

ENDIF.

**********************************************

ENDIF.

ELSE.

WRITE 'Goods Recieve has errors ..' .

LOOP AT it_return INTO wa_return.

WRITE: / wa_return-message.

ENDLOOP.

ENDIF.

***************************************************************************************

FORM upload_file TABLES p_it_tab

USING p_file.

FIELD-SYMBOLS : <fs>.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_file

i_begin_col = '1'

i_begin_row = '2'

i_end_col = '256'

i_end_row = '10000'

TABLES

intern = l_intern

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3

.

IF sy-subrc NE 0.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'File Error'.

EXIT.

ENDIF.

IF l_intern[] IS INITIAL.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'No Data Uploaded'.

EXIT.

ELSE.

SORT l_intern BY row col.

LOOP AT l_intern.

MOVE l_intern-col TO l_index.

ASSIGN COMPONENT l_index OF STRUCTURE p_it_tab TO <fs>.

MOVE l_intern-value TO <fs>.

AT END OF row.

APPEND p_it_tab.

CLEAR p_it_tab.

ENDAT.

ENDLOOP.

ENDIF.

ENDFORM.

----


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2008 at 06:02 AM

    Thanks for ur support

    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.