10-24-2012 2:02 PM
How can I append errors encountered from FM BAPI_PO_CREATE1 into a log file?
Hi experts,
Log file already exists, and will be loaded into the program.
And then errors encountered from the FM will be appended to the log file. How will I do this?
Thank you!
10-25-2012 7:13 AM
Dear Marlo,
After calling bapi CALL FUNCTION 'BAPI_PO_CREATE1
you can get all message in "return' tab.
loop at return into wa_return where message type = 'E'
move wa_return to gs_error_log.
append gs_error_log to gt_error_log.
endloop.
then pass final error table to below FM.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
read_by_line = 'X'
dat_mode = 'X'
TABLES
data_tab = gt_error_log[]
Hope above solution might help you.
Regards,
Amol
10-24-2012 2:11 PM
What do you mean by log file, is this the log displayed by transaction SLG1 ?
If yes, look at Create application log in BC Extended Applications Function Library :
Else save internal table RETURN to you database file (e.g. with an EXPORT TO DATABASE)
Regards,
Raymond
10-24-2012 3:03 PM
Hi Marlo,
From BAPI_PO_CREATE1, take the RETURN table in TABLES and update it to the log file. This will contain all the returnable errors. Take the message type as 'E' or 'A'. Rest should be ignored. For updating the log file, you need to move the messages to the format for the log file and then this can be appended.
Regards.
Hardik Mehta
10-24-2012 9:14 PM
Hi,
After executing BAPI_PO_CREATE1 FM it will returns all the messages related to the particular PO into table RETURN .
This table contains Message type and its message. You need to append related data to your log file as per the returns table data and your requirements.
Regards,
Venu
10-25-2012 6:26 AM
Hi Marlo,
You can use the RETURN table of BAPI_PO_CREATE1 to append the lines in error log table.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = wa_docheader
poheaderx = wa_docheaderx
* TESTRUN =
IMPORTING
exppurchaseorder = lv_po_no
TABLES
return = i_return
poitem = i_poitem
poitemx = i_poitemx
poschedule = i_poschedule
poschedulex = i_poschedulx
extensionin = i_extensionin
pocond = i_pocond.
Please check.
10-25-2012 7:13 AM
Dear Marlo,
After calling bapi CALL FUNCTION 'BAPI_PO_CREATE1
you can get all message in "return' tab.
loop at return into wa_return where message type = 'E'
move wa_return to gs_error_log.
append gs_error_log to gt_error_log.
endloop.
then pass final error table to below FM.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
read_by_line = 'X'
dat_mode = 'X'
TABLES
data_tab = gt_error_log[]
Hope above solution might help you.
Regards,
Amol