‎2006 Aug 10 4:55 PM
Good Afternoon,
I need to create a BDC calling transaction FOB1 (the table used for the BDC is <b>it_bdcdata</b>).
After calling the transaction i need to know which of posts where successfully processed in the transaction FOB1.
The reason i need to know that is because after the processing of the <b>it_bdcdata</b> in the transaction i need to update a table with the documents that where successfully created.
How can i, after calling the transaction, return to my program and analyze the data processed in the call transaction and update one of my tables in the system with only the successfull documents created in FOB1?
Regards,
Pedro Gaspar
‎2006 Aug 10 4:59 PM
hi do like this:
*--Calling the transaction 'fd01'.
CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
MESSAGES INTO IT_CUSTMSG.
IF SY-SUBRC <> 0.
*--Populating the error records internal table.
IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_ERRCUST.
CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
IF V_FLAG1 = ' '.
PERFORM FORM_OPENSESSION.
V_FLAG1 = 'X'.
ENDIF.
*--Inserting the error records into already open session.
IF V_FLAG1 = 'X'.
PERFORM FORM_INSERT.
ENDIF.
*--Populating the Success records internal table.
ELSE.
IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_SUCCUST.
CLEAR IT_SUCCUST.
ENDIF.
*--Displaying the messages.
IF NOT IT_CUSTMSG[] IS INITIAL.
PERFORM FORM_FORMATMSG.
ENDIF.
*--Clearing the message and bdc tables.
CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
ENDLOOP.
*--Getting the total no of error records.
DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
IF V_FLAG1 = 'X'.
PERFORM FORM_CLOSESESS.
ENDIF.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
DATA : LV_MSG(255).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 😕 LV_MSG.
ENDIF.
ULINE.
ENDFORM. " FORM_FORMATMSG
Message was edited by: Ashok Parupalli
‎2006 Aug 10 5:02 PM
do like this:
data: it_messages like bdcmsgcoll occurs 0.
call transaction 'FOB1' using bdcdata options from x_ctuparams messages into it_messages.
if sy-subrc = 0.
loop at it_messages where msgtyp = 'S'.
One of msgv1,msgv2,msgv3,msgv4 will have a number of the document that has bee created.
itab-number = it_messages-msgv1. "Or it may be 2,3,4 also
append itab.
endloop.
endif.
modify ztab from itab. "itab should have the same structue as the ztable.
Regards,
ravi
‎2006 Aug 10 5:05 PM
hi,
CALL TRANSACTION <tcode> USING IT_BDCDATA MODE 'A'
MESSAGES INTO IT_MESSTAB.
IF NOT IT_MESSTAB[] IS INITIAL.
PERFORM FORMAT_MESSAGES.
ENDIF.
FORM FORMAT_MESSAGES.
DATA : L_LINES TYPE I.
CLEAR: L_LINES,WA_IT_MESSTAB,V_MSG.
DESCRIBE TABLE IT_MESSTAB LINES L_LINES.
READ TABLE IT_MESSTAB INTO WA_IT_MESSTAB INDEX L_LINES.
IF SY-SUBRC = 0.
CLEAR V_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_IT_MESSTAB-MSGID
LANG = SY-LANGU
NO = WA_IT_MESSTAB-MSGNR
V1 = WA_IT_MESSTAB-MSGV1
V2 = WA_IT_MESSTAB-MSGV2
V3 = WA_IT_MESSTAB-MSGV3
V4 = WA_IT_MESSTAB-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 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.
ELSE.
*-- If the messge type is S then the records in it_file
*-- are taken as success records
IF WA_IT_MESSTAB-MSGTYP = C_S.
IT_SUCCESS[] = IT_FILE[].
ELSE.
READ TABLE IT_FILE WITH KEY MATNR = WA_IT_MESSTAB-MSGV3.
IF SY-SUBRC EQ 0.
IT_ERROR = IT_FILE.
APPEND IT_ERROR.
CLEAR IT_ERROR.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
‎2006 Aug 11 11:00 AM
All of you replys helped in understanding the question and solving it.
Thanks to all,
Pedro Gaspar