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

bapi_goodsmvt_create

hi all,

i created a functional module the purpose of this is to send an email to the distribution list when ever there is an error in processing the item.

every thing is working fine but a PO can have a number of items so in my program if the first item is error it is not processing the second item.

so can any one help me with logic how to process all the items in the PO if there is an error in some of the items.

here is my program.

"----


""Local Interface:

*" IMPORTING

*" VALUE(GOODSMVT_HEADER) LIKE BAPI2017_GM_HEAD_01 STRUCTURE

*" BAPI2017_GM_HEAD_01

*" VALUE(GOODSMVT_CODE) LIKE BAPI2017_GM_CODE STRUCTURE

*" BAPI2017_GM_CODE

*" VALUE(TESTRUN) LIKE BAPI2017_GM_GEN-TESTRUN DEFAULT SPACE

*" EXPORTING

*" VALUE(GOODSMVT_HEADRET) LIKE BAPI2017_GM_HEAD_RET STRUCTURE

*" BAPI2017_GM_HEAD_RET

*" VALUE(MATERIALDOCUMENT) TYPE BAPI2017_GM_HEAD_RET-MAT_DOC

*" VALUE(MATDOCUMENTYEAR) TYPE BAPI2017_GM_HEAD_RET-DOC_YEAR

*" TABLES

*" GOODSMVT_ITEM STRUCTURE BAPI2017_GM_ITEM_CREATE

*" GOODSMVT_SERIALNUMBER STRUCTURE BAPI2017_GM_SERIALNUMBER

*" OPTIONAL

*" RETURN STRUCTURE BAPIRET2

*"----


ET PLANT AND STORAGE LOC TO THE INTERNAL TABLE.

DESCRIBE TABLE goodsmvt_item LINES w_no_lines.

IF w_no_lines > 0.

SELECT ebeln ebelp werks lgort

FROM ekpo

INTO TABLE t_ekpo FOR ALL ENTRIES IN goodsmvt_item

WHERE

ebeln = goodsmvt_item-po_number AND

ebelp = goodsmvt_item-po_item.

ENDIF.

  • GET THE VENDOR NUMBER.

CLEAR w_lifnr.

SELECT SINGLE lifnr INTO w_lifnr

FROM ekko

WHERE ebeln = goodsmvt_item-po_number.

  • MODIFY THE ITEMS TABLE.

LOOP AT goodsmvt_item.

CLEAR t_ekpo.

READ TABLE t_ekpo WITH KEY ebeln = goodsmvt_item-po_number

ebelp = goodsmvt_item-po_item.

IF sy-subrc = 0.

goodsmvt_item-plant = t_ekpo-werks.

goodsmvt_item-stge_loc = t_ekpo-lgort.

MODIFY goodsmvt_item TRANSPORTING plant stge_loc.

ENDIF.

endloop.

  • Execute Goods Receipt for PO

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = goodsmvt_header

goodsmvt_code = '01' "from table t158g for mb01

  • TESTRUN = ' '

IMPORTING

goodsmvt_headret = goodsmvt_headret

materialdocument = materialdocument

matdocumentyear = matdocumentyear

TABLES

goodsmvt_item = goodsmvt_item

goodsmvt_serialnumber = goodsmvt_serialnumber

return = t_return.

  • CHECK WHETHER MAT DOC NO IS CREATED.

IF materialdocument = space.

CLEAR w_lv_fname.

w_lv_fname = goodsmvt_item-entry_qnt.

SHIFT w_lv_fname LEFT DELETING LEADING space.

CLEAR w_temp_flag.

  • MOVE THE ERROR MESSAGE TO THE INTERNAL TABLE.

LOOP AT t_return WHERE type = 'E'.

IF w_temp_flag NE t_return-row.

READ TABLE goodsmvt_item INDEX w_temp_flag.

CONCATENATE 'The following errors were detected when posting GR For'

'PO NO' goodsmvt_item-po_number

'PLANT' goodsmvt_item-plant

'STORAGE LOC' goodsmvt_item-stge_loc

'MATERIAL' goodsmvt_item-material

'MOVEMENT TYPE' goodsmvt_item-move_type

'QUANTITY' w_lv_fname

'SERIAL NO' goodsmvt_serialnumber-serialno

'PO ITEM NO' goodsmvt_item-po_item

INTO t_msg SEPARATED BY space.

APPEND t_msg.

w_temp_flag = t_return-row.

ENDIF.

MOVE t_return TO t_msg.

APPEND t_msg.

ENDLOOP.

  • EMAIL SUBJECT.

w_subject = .gr fail'.

  • CHECK THE NAME OF THE SAP SYSTEM.

IF sy-sysid = 'PRD'.

  • Get vendor-specific distribution list

CALL FUNCTION 'Z_GET_DISTRIBUTION'

EXPORTING

application = c_application

application_group = w_lifnr

IMPORTING

address_list = w_address_list.

ELSE.

  • Get test user group distribution list

CALL FUNCTION 'Z_GET_DISTRIBUTION'

EXPORTING

application = c_application

application_group = c_test

IMPORTING

address_list = w_address_list.

ENDIF.

  • SEND EMAIL TO THE DISTRIBUTION LIST.

CALL FUNCTION 'Z_UNIX_MAIL'

EXPORTING

ux_receivers = w_address_list

ux_subject = w_subject

  • UX_FROM =

TABLES

ux_lines = t_msg.

ELSE.

COMMIT WORK AND WAIT.

ENDIF.

ENDFUNCTION.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 25, 2006 at 09:21 PM

    Please see my response to this post in the other forum and close this thread.

    Rob

    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.