‎2013 Dec 24 8:45 AM
Hi,
I have an issue where in I have to upload a file which consists of 5 VALID and 5 INVALID TI-KODES(The FIELD).
After the file is uploaded and executed I have to get 2 different messages,
1. Success message saying 5 TI-KODES were uploaded
2. Error message saying 5 TI-KODES are INVALID..
Right now if I upload the file,,because of the INVALID TI-KODES the VALID TI-KODES are also not uploading
here is what i have tried to do,
FIELD-SYMBOLS <fs_tikode> LIKE LINE OF gt_dataset.
FIELD-SYMBOLS <fs_validate> LIKE LINE OF IT_DIGOFF_FITIKODE.
SELECT tikode from /DIGOFF/FITIKODE INTO TABLE IT_DIGOFF_FITIKODE.
LOOP AT gt_dataset ASSIGNING <fs_tikode>.
IF <fs_tikode>-tikode is not INITIAL.
READ TABLE IT_DIGOFF_FITIKODE ASSIGNING <fs_validate> WITH KEY tikode = <fs_tikode>-tikode.
if sy-subrc NE 0.
MESSAGE E045(FAGL_POST_SERVICE) WITH <fs_tikode>-tikode MSG.
ENDIF.
ENDIF.
ENDLOOP.
Can anyone help me with this..
Regards,
Sanjeeth
‎2013 Dec 24 9:10 AM
Hi SAnjeeth
dont raise an error message. It will stop the processing. Append into an internal table of type BAPIRET2
Nabheet
‎2013 Dec 24 8:57 AM
Hi Sanjeeth,
for error messages why not you use the BAPI,
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
it will give you all the details for all those data, that are successfully uploaded
and those data that are having error.
‎2013 Dec 24 9:02 AM
Hi Sanjeeth,
you can write your code logic as written below, just change it as your requirements (for fields)
It will give for all error and success messages, please try this code
DATA : BEGIN OF options.
INCLUDE STRUCTURE ctu_params.
DATA : END OF options.
DATA: i_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
l_message LIKE bapiret2-message.
DATA: p_mode TYPE c.
DATA BEGIN OF it_error OCCURS 1.
DATA : text(100) TYPE c.
DATA END OF it_error.
DATA BEGIN OF it_success OCCURS 1.
DATA: text(100) TYPE c.
DATA END OF it_success.
DATA: it_raw TYPE truxs_t_text_data.
CALL TRANSACTION 'FB01' USING bdcdata
OPTIONS FROM options
MESSAGES INTO i_messtab.
IF SY-SUBRC NE 0.
CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL'
EXPORTING
id = sy-msgid
number = sy-msgno
language = sy-langu
textformat = 'ASC'
message_v1 = sy-msgv1
message_v2 = sy-msgv2
message_v3 = sy-msgv3
message_v4 = sy-msgv4
IMPORTING
message = l_message.
.
CONCATENATE l_message '-' wa_input-newko wa_input-wrbtr wa_input-budat INTO it_error-text
SEPARATED BY ' '.
APPEND it_error.
ELSE.
CONCATENATE 'DATA UPLOADED SUCCESSFULLY :' wa_input-newko wa_input-wrbtr wa_input-budat
INTO it_success-text SEPARATED BY ' '.
APPEND it_success.
ENDIF.
REFRESH bdcdata.
CLEAR: wa_input,l_message.
‎2013 Dec 24 9:10 AM
Hi SAnjeeth
dont raise an error message. It will stop the processing. Append into an internal table of type BAPIRET2
Nabheet
‎2013 Dec 24 9:12 AM
Hi Sanjeet,
I don't know the business expectations. I understand that you want to consolidate the error log as well as success log after loading the file into SAP.
FIELD-SYMBOLS <fs_tikode> LIKE LINE OF gt_dataset.
FIELD-SYMBOLS <fs_validate> LIKE LINE OF IT_DIGOFF_FITIKODE.
SELECT tikode from /DIGOFF/FITIKODE INTO TABLE IT_DIGOFF_FITIKODE.
LOOP AT gt_dataset ASSIGNING <fs_tikode>.
IF <fs_tikode>-tikode is not INITIAL.
READ TABLE IT_DIGOFF_FITIKODE ASSIGNING <fs_validate> WITH KEY tikode = <fs_tikode>-tikode.
if sy-subrc NE 0.
*MESSAGE E045(FAGL_POST_SERVICE) WITH <fs_tikode>-tikode MSG.
consolidate the error log into internal table by using the FM
*build the internal table with the required information
MESSAGE_TEXT_BUILD
ELSE.
*build the internal table with the required information
CONSOLIDATE SUCCESS messages into one more internal table for success
ENDIF.
ENDIF.
ENDLOOP.