11-07-2006 5:45 AM
After handling the errors how we will upload the error data into the db in call transaction?
11-07-2006 5:55 AM
11-07-2006 6:00 AM
hai thanks
What r the parameters we hav to fill in format_message FM?
11-07-2006 5:57 AM
The BDCMSGCOLL does not have the messages text. It has only the message type, number and message parameters.
You have to read the message text. (recall that the database table T100 stores all the messages.)
There are more than one method of doing this.
Following is the psuedocode for one of the methods.
LOOP for the internal table IT1 which has data value from flat file.
call transcation using....
if SY-SUBRC <> 0.
Read the dictionary table T100 FOR ALL ENTRIES in BDCMSGCOLL.
(also use the condition T100-SPRAS = SY-LANGU (the log on language. This is because you need only the message texts in English if the user is logged in English language)
IF message type is E , then, transfer the contents of this particular error record to file x. (TRANSFER......)
( Ignore all other messages. Only consider type 'E' messages. Ignore other types of messages.)
(You can also store the message text from T100 and the error record in another internal table IT2)
.....
....
ENDLOOP.
Alternatively,
Instead of
" Read the dictionary table T100 FOR ALL ENTRIES in BDCMSGCOLL."
you can use the function module
WRITE_MESSAGES to read the messages.
Please refer to the function module for the list of parameters.
Also refer FORMAT_MESSAGES function module.
Best Regards,
Vibha Deshmukh
*Plz mark useful answers
<b>One request for you, for the queries that you have, if they have got satisfactry answers, please mark the useful answers as many abapers are helping you out.</b>
11-07-2006 6:00 AM
this code transfeers all the error msgs to an internal table..ERROR_ITAB
*&---------------------------------------------------------------------*
& Include zINCLUDE
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* data definition
*----------------------------------------------------------------------*
* Batchinputdata of single transaction
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
* messages of call transaction
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
* error session opened (' ' or 'X')
DATA: E_GROUP_OPENED.
* message texts
TABLES: T100 , crhd.
data : itab_crhd like table of crhd with header line.
DATA : NODATA VALUE '/',
CTUMODE LIKE CTU_PARAMS-DISMODE VALUE 'N',
CUPDATE LIKE CTU_PARAMS-UPDMODE VALUE 'L'.
DATA : ERR TYPE STRING.
DATA : RC TYPE I,
successcnt type i value 0,
failcount type i value 0.
data : cntr type i value 0.
AT SELECTION-SCREEN.
FORM OPEN_DATASET USING P_DATASET.
OPEN DATASET P_DATASET
FOR INPUT IN TEXT MODE
ENCODING DEFAULT.
IF SY-SUBRC <> 0.
WRITE: / TEXT-E00, SY-SUBRC.
STOP.
ENDIF.
ENDFORM.
FORM CLOSE_DATASET USING P_DATASET.
CLOSE DATASET P_DATASET.
ENDFORM.
FORM BDC_TRANSACTION USING TCODE .
DATA: L_MSTRING(480).
DATA : BEGIN OF ERROR_ITAB OCCURS 0,
ERROR(50),
MSGTYP,
END OF ERROR_ITAB.
DATA : WA LIKE LINE OF ERROR_ITAB.
DATA: L_SUBRC LIKE SY-SUBRC.
REFRESH MESSTAB.
CALL TRANSACTION TCODE USING BDCDATA
MODE 'N'
UPDATE 'L'
MESSAGES INTO MESSTAB.
L_SUBRC = SY-SUBRC.
LOOP AT MESSTAB.
if messtab-msgtyp eq 'E'.
SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
AND ARBGB = MESSTAB-MSGID
AND MSGNR = MESSTAB-MSGNR.
IF SY-SUBRC = 0.
L_MSTRING = T100-TEXT.
IF L_MSTRING CS '&1'.
REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ELSE.
REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
ENDIF.
CONDENSE L_MSTRING.
MOVE L_MSTRING TO ERROR_ITAB-ERROR.
MOVE MESSTAB-MSGTYP TO ERROR_ITAB-MSGTYP.
APPEND ERROR_ITAB.
* delete error_itab where msgtyp = 'S'.
ELSE.
MOVE MESSTAB TO ERROR_ITAB-ERROR.
APPEND ERROR_ITAB.
ENDIF.
clear itab_crhd.
refresh itab_crhd.
11-07-2006 6:36 AM
Hi,
declare original internal table, success record internal table and error record internal table where the records which r not uploaded into d/b will be stored.
DATA : itab2 LIKE itab OCCURS 0 WITH HEADER LINE,
it_success LIKE itab OCCURS 0 WITH HEADER LINE,
it_error LIKE itab OCCURS 0 WITH HEADER LINE.
declare a internal table table of structure bdcmsgcoll
DATA : bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,
t_bdcmsgcoll LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
after the call transaction statement call the function format_message
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = '-D'
no = sy-msgno
v1 = sy-msgv1
v2 = sy-msgv2
v3 = sy-msgv3
v4 = sy-msgv4
IMPORTING
msg = t_bdcmsgcoll
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.
ENDIF.
move the records which r not uploaded into it_error and the records which r uploaded to it_success.