Application Development 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: 

How can I append errors encountered from FM BAPI_PO_CREATE1 into a log file?

Former Member
0 Kudos

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!

1 ACCEPTED SOLUTION

amol_samte
Contributor
0 Kudos

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

5 REPLIES 5

raymond_giuseppi
Active Contributor
0 Kudos

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 :

  • BAL_LOG_CREATE Open a log
  • BAL_LOG_MSG_ADD Put a message in the log
  • BAL_DSP_LOG_DISPLAY Display log

Else save internal table RETURN to you database file (e.g. with an EXPORT TO DATABASE)

Regards,

Raymond

Former Member
0 Kudos

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

Former Member
0 Kudos

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    

0 Kudos

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.

amol_samte
Contributor
0 Kudos

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