09-18-2008 12:35 AM
Hi Experts,
The following code produces error "No message generated for output of purchasing document". This prevents the BAPI from saving the document. This error is actually a yellow warning. When completing the changes manually in ME22N the user has the option to ignore warnings & save.
Is there any code which can be added so that yellow warnings are ignored?
Thanks for your time.
Here is my complete code:
REPORT Z_MASS_REMOVE_FDI_DCI_BAPI.
*head
PARAMETERS: p_ebeln LIKE bapimepoheader-po_number OBLIGATORY.
*Item
PARAMETERS :p_ebelp LIKE bapimepoitem-po_item DEFAULT 1.
DATA: s_header TYPE bapimepoheader,
s_headerx TYPE bapimepoheaderx,
s_item TYPE bapimepoitem,
s_itemx TYPE bapimepoitemx,
i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
s_bapimepoheader TYPE bapimepoheader,
s_bapimepoheaderx TYPE bapimepoheaderx,
s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,
s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,
wa_message TYPE c LENGTH 100.
s_bapimepoheaderx-po_number = p_ebeln.
s_bapimepoheader-po_number = p_ebeln.
s_bapimepoitemx-PO_ITEM = p_ebelp.
s_bapimepoitem-PO_ITEM = p_ebelp.
s_bapimepoitemx-DELIV_COMPL = 'X'.
s_bapimepoitem-DELIV_COMPL = 'X'.
append s_bapimepoitem.
clear s_bapimepoitem.
append s_bapimepoitemx.
clear s_bapimepoitemx.
s_header-po_number = p_ebeln.
S_item-PO_ITEM = p_ebelp.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = p_ebeln
TABLES
return = i_return
poitem = s_bapimepoitem
poitemx = s_bapimepoitemx.
COMMIT WORK AND WAIT.
LOOP AT i_return.
MESSAGE ID i_return-id
TYPE i_return-type
NUMBER i_return-number WITH
i_return-message_v1
i_return-message_v2
i_return-message_v3
i_return-message_v4.
ENDLOOP.
09-18-2008 4:30 AM
Hi Nathan ,
u need to config output types of PO, this can done thru Tcode NACE.
if u want to ignore this message from ur code , then u need do one thing.
u need to delete this message from the Internal table RETURN based on the Message ID , Type , No.
sameple code
DELETE GT_MSSG WHERE ( MESSAGE_TYPE EQ 'E' AND
MESSAGE_NO EQ '525' AND
MESSAGE_ID EQ 'CL' ).
regards
Prabhu
09-18-2008 4:30 AM
Hi Nathan ,
u need to config output types of PO, this can done thru Tcode NACE.
if u want to ignore this message from ur code , then u need do one thing.
u need to delete this message from the Internal table RETURN based on the Message ID , Type , No.
sameple code
DELETE GT_MSSG WHERE ( MESSAGE_TYPE EQ 'E' AND
MESSAGE_NO EQ '525' AND
MESSAGE_ID EQ 'CL' ).
regards
Prabhu
09-18-2008 5:04 AM
Prabhu you are a champion.
Using your sample code I have added the following. The query now works perfectly.
*Ignore Message Output "No message generated for output of purchasing document"
DELETE i_return WHERE ( TYPE EQ 'W' AND NUMBER EQ '261' ).
*Ignore Message Output "Mandatory roles missing in partner maintenance"
DELETE i_return WHERE ( TYPE EQ 'W' AND NUMBER EQ '366' ).
COMMIT WORK AND WAIT.
09-18-2008 5:08 AM
Hi Nathan ,
u need to remember one thing when u are working on BAPI's.
first u need to check if any errors/logs in the return table , then only u need to commit the work.
read table return with key type = 'E'.
if sy-subrc ne 0.
commit work or Call BAPI_TRANSACTION_COMMIT.
endif.
Njoy SAP.
regards
Prabhu
09-18-2008 7:12 AM
I have updated the code to use a TXT file as data source (and incorporated the check for error before committing)
For some reason when working with a multi-line document it changes ALL lines, not just the specified line. i.e. if document has two lines and I wish to update line 2 it updates both lines 1 and 2.
My previous code (as per original post) worked perfectly - it only updated the specified line items. But this code used parameters for one document at a time.
Any idea why the BAPI is ignoring the line item? The WRITE function is clearly outputting the item number, so I know it is reading the text file correctly.
Here is my complete code:
REPORT Z_MASS_REMOVE_FDI_DCI_BAPI.
TYPES: BEGIN OF ty_tab,
DOCNO(10),
ITEM(4),
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab.
DATA : wa_tab TYPE ty_tab.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'X:\STO.TXT'
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = it_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
END-OF-SELECTION.
LOOP AT it_tab INTO wa_tab.
WRITE:/ 'DOCUMENT: ',
wa_tab-DOCNO,
' ITEM: ',
wa_tab-ITEM.
DATA: s_header TYPE bapimepoheader,
s_headerx TYPE bapimepoheaderx,
s_item TYPE bapimepoitem,
s_itemx TYPE bapimepoitemx,
i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
s_bapimepoheader TYPE bapimepoheader,
s_bapimepoheaderx TYPE bapimepoheaderx,
s_bapimepoitem TYPE bapimepoitem occurs 0 with header line,
s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,
wa_message TYPE c LENGTH 100.
s_bapimepoheaderx-po_number = wa_tab-DOCNO.
s_bapimepoheader-po_number = wa_tab-DOCNO.
s_bapimepoitemx-PO_ITEM = wa_tab-ITEM.
s_bapimepoitem-PO_ITEM = wa_tab-ITEM.
* Remove Outwards Delivery Complete Indicator (FDI)
s_bapimepoitemx-DELIV_COMPL = 'X'.
s_bapimepoitem-DELIV_COMPL = ' '.
* Remove Delivery Complete Indicator (DCI)
s_bapimepoitemx-NO_MORE_GR = 'X'.
s_bapimepoitem-NO_MORE_GR = ' '.
* Remove Deletion Indicator
s_bapimepoitemx-DELETE_IND = 'X'.
s_bapimepoitem-DELETE_IND = ' '.
append s_bapimepoitem.
clear s_bapimepoitem.
append s_bapimepoitemx.
clear s_bapimepoitemx.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = wa_tab-DOCNO
TABLES
return = i_return
poitem = s_bapimepoitem
poitemx = s_bapimepoitemx.
**Message types: S Success, E Error, W Warning, I Info, A Abort
*Ignore all Warning Messages
DELETE i_return WHERE ( TYPE EQ 'W' ).
read table i_return with key type = 'E'.
if sy-subrc ne 0.
Call FUNCTION 'BAPI_TRANSACTION_COMMIT'.
endif.
*Display Return Messages on Screen
LOOP AT i_return.
WRITE: / 'RETURN MESSAGE: ',
'ID: ',
i_return-id,
' TYPE: ',
i_return-type,
' NUMBER: ',
i_return-number,
' ',
i_return-message.
WRITE: / '-----------------------------------------------------------------------'.
ENDLOOP.
ENDLOOP.
09-18-2008 7:26 AM
Hi Nathan ,
i'm just giving the idea on it, before that i need to know , what kind of inputs u will get ? do u get PO no and Items as well ? or only PO no ?
case 1.
if u get PO no as a Input then
step1. Get all PO items data from table EKPO for give PO no.
step 2. loop at po_header.
refresh all internal tables used in the BAPI.
loop at po_item where eblen = po_header-eblen
here u need to populate all required tables for BAPI
call BAPI.
commit work if no errors.
maintain internal(global) for all Message .
endloop.
endloop.
if u get PO+Item ,update BAPI tables based on the PO no.
regards
Prabhu
09-18-2008 7:49 AM
Hi Prabhu,
I am passing both PO NUMBER and ITEM NUMBER from a text file. I then loop through wa_tab and update the BAPI. Very similar to the structure you propose. I must be missing something very minor, because it loops through the PO NUMBER correctly, just not the ITEM NUMBER.
TYPES: BEGIN OF ty_tab,
DOCNO(10),
ITEM(4),
END OF ty_tab.
DATA : it_tab TYPE STANDARD TABLE OF ty_tab.
DATA : wa_tab TYPE ty_tab.
09-18-2008 8:45 AM
I've figured it out, I needed to refresh the bapi items.
The following code has been added to the end of the loop:
refresh : s_bapimepoitem,s_bapimepoitemx.
Thanks for your help Prabhu, much appreciated.
11-25-2009 2:54 PM