Error in session method ?
How to handle error in session method ?
while to tranfer the data from the through if any errors occurs until the errors are the complete the data is not tranfer to the sap system.
the system compalsory shows the errors .that errors are stored into the error logs (Trasaction is SM35).
so the sesion method should not return any value.
in call trasaction method data is directly pass to the sap system.
so its compalsory return the value.
because of the call trasaction is the funtion.
a funtion should return the value madatory.
Similar Messages
-
How to download error records after the session method executed in BDC?
Dear Experts,
How to download errors in session method after executing session method. Please dn't say for BDCMSGCOLL i have goggled all . every one answer for call transaction. In session method after executing we fill find all the success and errors in log file . But how to download this log file?
please help me.
Thanks
RavillaHi Laxman,
Please find the below process .I hope this will suits to your requirement .
1)Write an error report.
2)Send the record(s) in error to an error file.
3)Create a BATCH input session with the record(s) in error.
To store error MESSAGES ( CALL TRANSACTION )
data: begin of Tab_Mess occurs 0.
include structure bdcmsgcoll.
data : end of Tab_Mess,
CALL TRANSACTION ‘FK02’ USING BDC_TAB MODE ‘N’ UPDATE ‘S’
MESSAGES INTO TAB_MESS.
IF SY-SUBRC NE 0.
WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,
Tab_MESS-MSGID.
ENDIF.
Regards,
Bharat Kumar -
Error message log in session method of ALV report,
In ALV report please let me know:
1) In session method:
where all error messages are stored,I know that error messages are stored in a log file, so please tell me where is it stored.
2)transaction method:
How to handle error messages in transaction methos(for eg if a weight field text box value is negative)Ans for 2nd point.
CALL TRANSACTION c_mb USING i_bdcdata
MODE g_ctumode
UPDATE g_cupdate
MESSAGES INTO i_messtab.
COMMIT WORK.
IF sy-subrc EQ 0. " BDC Executed Successfully
CLEAR wa_messtab.
LOOP AT i_messtab INTO wa_messtab .
IF wa_messtab-msgtyp = 'S' AND
wa_messtab-msgid = 'M7' AND
wa_messtab-msgnr = '060'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
APPEND l_msg TO i_sucsess.
CLEAR l_msg.
g_docsuc = 1.
ELSE.
IF wa_messtab-msgtyp = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
g_errflg = 1.
APPEND l_msg TO i_error.
CLEAR: l_msg.
ENDIF. -
Error in my BDC SESSION METHOD
Hi,
I was trying work on BDC SESSION METHOD AND MY TCODE IS XK01.
Here is my code can some one tell me where i am doing wrong becoz its not giving the output as I expected. And I am uploading a tab delimeter file.
report ZAN_BDCVENDOR
no standard page heading line-size 255.
include bdcrecx1.
DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF RECORD OCCURS 0,
LIFNR(016),
BURKS(004),
EKORG(004),
KTOKK(004),
AKONT(010),
FDGRV(010),
WAERS(005),
END OF RECORD.
start-of-selection.
perform open_group.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\VENDOR.TXT'
FILETYPE = 'ASC'
tables
data_tab = RECORD
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT RECORD.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'USE_ZAV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
'8765'.
perform bdc_field using 'RF02K-BUKRS'
'1000'.
perform bdc_field using 'RF02K-EKORG'
'1000'.
perform bdc_field using 'RF02K-KTOKK'
'0001'.
perform bdc_field using 'USE_ZAV'
'X'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFB1-AKONT'
'160000'.
perform bdc_field using 'LFB1-FDGRV'
'A1'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFM1-WAERS'
'usd'.
perform bdc_transaction using 'XK01'.
ENDLOOP.
perform close_group.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'SESSION1'
HOLDDATE = FILLER8
KEEP = FILLER1
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID = 3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR = 7
RUNNING = 8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11
IF sy-subrc <> 0.
WRITE 'ERROR IN OPEN_GROUP'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = I_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I appreciateHi,
i guess, the error is due to, u didnt pass the TCODE parameter in BDC_INSERT FM.
Try by passing it...
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE*
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = I_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
Hope it works!!
Regards,
Pavan -
How to handle the errors in BDC Session method
Hi All,
I am uploading Material Master (MM01) records using BDC Session Method.my problem is when i am running the program, all the error records are going to flat file.how can i correcting the error records and after correction how can i re-process the error records.tell me with example.
i have around 70,000 records in my flat file.Hi,
I am attaching few threads.Hope these will help you.
If there are any error records in session, all those error records will get poulated in log .SM35 and after the session is completed , u can see error records which can be corrected and reprocessed again
We have the structures BDCLD and BDCLM, which will capture the log details inthe session. Firstly, sesssion should be processed. After that log will be created. Then caputure the information into an internal table using BDCLM and BDCLD.
and refer the link.
error correction in bdc session
regards
Madhu -
Error in CALL TRANSACTION and SESSION Method
I have 8 records (1,2,3,4,5,6,7,8) to update into SAP database using CALL TRANSACTION and SESSION Method. If there is a error in 6th record. What happens in both call transaction and session method.
Please let me know which records will process and what about the error record. How to process only the error record if all other records have updated into database.Hi Patil_sumeet,
if your code for this is not protected secret of some federal agency, you may read [How to post code in SCN, and some things NOT to do...|How to post code in SCN, and some things NOT to do...; and then post relevant lines here.
According to the facts presented until know it may have been better to ask Radio Eriwan
Regards
Clemens -
Error occured in bdc(session method)
hai,
i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
this problem happening at when i was going to give the file path through f4 in selection screen it's showing like BDC_OPEN_GROUP, group .. is invalid
iam sending my coding also plz give me the clarifications abt this one.
SESSION METHOD **********************
TYPES : BEGIN OF TY_DATA,
LIFNR TYPE LIFNR,
EKORG TYPE EKORG,
KTOKK TYPE KTOKK,
NAME1 TYPE NAME1_GP,
SORTL TYPE SORTL,
LAND1 TYPE LAND1_GP,
WAERS TYPE BSTWA,
END OF TY_DATA.
DATA : WA_DATA TYPE TY_DATA,
WA_BDCDATA TYPE BDCDATA,
WA_BDCMSGCOLL TYPE BDCMSGCOLL.
DATA : IT_DATA TYPE TABLE OF TY_DATA,
IT_BDCDATA TYPE TABLE OF BDCDATA,
IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
DATA : V_FILE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
P_GROUP LIKE APQI-GROUPID OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
PERFORM GET_F4_FOR_FILE USING PA_FILE.
V_FILE = PA_FILE.
PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
PERFORM OPEN_SESSION USING P_GROUP.
LOOP AT IT_DATA INTO WA_DATA.
REFRESH IT_BDCDATA.
FIRST SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
**** FIELD DETAILS
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
**** FILED LIFNR
PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
FIELD EKORG
PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
**** FIELD KTOKK
PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
SECOND SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
field NAME
PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
field LAND1
PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
THIRD SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
******** field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
ENDLOOP.
PERFORM CLOSE_SESSION.
*& Form GET_F4_FOR_FILE
FORM GET_F4_FOR_FILE USING P_PA_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'PA_FILE'
CHANGING
FILE_NAME = PA_FILE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_F4_FOR_FILE
*& Form UPLOAD_FILE_TO_ITAB
FORM UPLOAD_FILE_TO_ITAB USING FP_V_FILE
CHANGING FP_IT_DATA LIKE IT_DATA.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FP_V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = FP_IT_DATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " UPLOAD_FILE_TO_ITAB
*& Form OPEN_SESSION
FORM OPEN_SESSION USING FP_P_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = FP_P_GROUP
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
IF SY-SUBRC = 0.
WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
ENDIF.
ENDFORM. " OPEN_SESSION
*& Form FILL_SCREEN_DETAILS
FORM FILL_SCREEN_DETAILS USING PROGRAM
DYNPRO
DYNBEGIN.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = DYNBEGIN.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_SCREEN_DETAILS
*& Form FILL_FIELD_DETAILS
FORM FILL_FIELD_DETAILS USING FNAM FVAL.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_FIELD_DETAILS
*& Form BDC_INSERT
FORM BDC_INSERT USING FP_TCODE TYPE SYTCODE
FP_IT_BDCDATA LIKE IT_BDCDATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = FP_TCODE
TABLES
DYNPROTAB = FP_IT_BDCDATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_INSERT
*& Form CLOSE_SESSION
FORM CLOSE_SESSION .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_SESSIONhai,
i was written one bdc program with session method but unfortunatly it's throwing some error like bdc_group is invalid.
this problem happening at when i was going to give the file path through f4 in selection screen it's showing like BDC_OPEN_GROUP, group .. is invalid
iam sending my coding also plz give me the clarifications abt this one.
SESSION METHOD **********************
TYPES : BEGIN OF TY_DATA,
LIFNR TYPE LIFNR,
EKORG TYPE EKORG,
KTOKK TYPE KTOKK,
NAME1 TYPE NAME1_GP,
SORTL TYPE SORTL,
LAND1 TYPE LAND1_GP,
WAERS TYPE BSTWA,
END OF TY_DATA.
DATA : WA_DATA TYPE TY_DATA,
WA_BDCDATA TYPE BDCDATA,
WA_BDCMSGCOLL TYPE BDCMSGCOLL.
DATA : IT_DATA TYPE TABLE OF TY_DATA,
IT_BDCDATA TYPE TABLE OF BDCDATA,
IT_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL.
DATA : V_FILE TYPE STRING.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER : PA_FILE LIKE FC03TAB-PL00_FILE, "OBLIGATORY default 'C:\MAHESH\IT_FILE.TXT'
P_GROUP LIKE APQI-GROUPID OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR PA_FILE.
PERFORM GET_F4_FOR_FILE USING PA_FILE.
V_FILE = PA_FILE.
PERFORM UPLOAD_FILE_TO_ITAB USING V_FILE CHANGING IT_DATA.
PERFORM OPEN_SESSION USING P_GROUP.
LOOP AT IT_DATA INTO WA_DATA.
REFRESH IT_BDCDATA.
FIRST SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0107' 'X'.
**** FIELD DETAILS
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'RF02K-KTOKK'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '/00'.
**** FILED LIFNR
PERFORM FILL_FIELD_DETAILS USING 'RF02K-LIFNR' WA_DATA-LIFNR.
FIELD EKORG
PERFORM FILL_FIELD_DETAILS USING 'RF02K-EKORG' WA_DATA-EKORG.
**** FIELD KTOKK
PERFORM FILL_FIELD_DETAILS USING 'RF02K-KTOKK' WA_DATA-KTOKK.
SECOND SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0110' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'lfa1-land1'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
field NAME
PERFORM FILL_FIELD_DETAILS USING 'LFA1-NAME1' WA_DATA-NAME1.
field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFA1-SORTL' WA_DATA-SORTL.
field LAND1
PERFORM FILL_FIELD_DETAILS USING 'LFA1-LAND1' WA_DATA-LAND1.
THIRD SCREEN DETAILS
PERFORM FILL_SCREEN_DETAILS USING 'SAPMF02K' '0310' 'X'.
FIELD CURSOR
PERFORM FILL_FIELD_DETAILS USING 'BDC_CURSOR' 'LFM1-WAERS'.
OK CODES
PERFORM FILL_FIELD_DETAILS USING 'BDC_OKCODE' '=upda'.
******** field SORTL
PERFORM FILL_FIELD_DETAILS USING 'LFM1-WAERS' WA_DATA-WAERS.
PERFORM BDC_INSERT USING 'MK01' IT_BDCDATA.
ENDLOOP.
PERFORM CLOSE_SESSION.
*& Form GET_F4_FOR_FILE
FORM GET_F4_FOR_FILE USING P_PA_FILE.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
FIELD_NAME = 'PA_FILE'
CHANGING
FILE_NAME = PA_FILE.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_F4_FOR_FILE
*& Form UPLOAD_FILE_TO_ITAB
FORM UPLOAD_FILE_TO_ITAB USING FP_V_FILE
CHANGING FP_IT_DATA LIKE IT_DATA.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FP_V_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = FP_IT_DATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " UPLOAD_FILE_TO_ITAB
*& Form OPEN_SESSION
FORM OPEN_SESSION USING FP_P_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = FP_P_GROUP
HOLDDATE = FILLER8
KEEP = 'X'
USER = SY-UNAME
IF SY-SUBRC = 0.
WRITE : / 'PROCESS THE SESSION',FP_P_GROUP,'USING SM35'.
ENDIF.
ENDFORM. " OPEN_SESSION
*& Form FILL_SCREEN_DETAILS
FORM FILL_SCREEN_DETAILS USING PROGRAM
DYNPRO
DYNBEGIN.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = DYNBEGIN.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_SCREEN_DETAILS
*& Form FILL_FIELD_DETAILS
FORM FILL_FIELD_DETAILS USING FNAM FVAL.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDFORM. " FILL_FIELD_DETAILS
*& Form BDC_INSERT
FORM BDC_INSERT USING FP_TCODE TYPE SYTCODE
FP_IT_BDCDATA LIKE IT_BDCDATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = FP_TCODE
TABLES
DYNPROTAB = FP_IT_BDCDATA.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_INSERT
*& Form CLOSE_SESSION
FORM CLOSE_SESSION .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " CLOSE_SESSION -
Hello friends,
Is it possible to create error log in session method, just like call transaction ( BDCMSGCOLL) . I want to create error log.
Is it possible or not, If possible how ?
Please let me know the answer.
Thanks,
AjayHi,
* To catch no. of lines in itab.
DESCRIBE TABLE itab LINES trec.
* To catch no. of lines in it_err.
DESCRIBE TABLE it_err LINES erec.
* Calculation for records which are successfully uploaded.
srec = trec - erec.
* Layout for display summary begin.
WRITE:(60) sy-uline..
WRITE:/ sy-vline, ' SUMMARY OF TRANSACTION '
COLOR COL_HEADING,60 sy-vline..
WRITE:/(60) sy-uline..
WRITE:/ sy-vline, 'TOTAL NO. OF RECORDS ' COLOR
COL_TOTAL, 46 sy-vline, 50 trec LEFT-JUSTIFIED, 60 sy-vline.
WRITE:/(60) sy-uline.
WRITE:/ sy-vline, 'No Of Records Not Uploaded Successfully are:' COLOR
COL_NEGATIVE HOTSPOT ON,50 erec LEFT-JUSTIFIED, 46 sy-vline,60
sy-vline.
WRITE:/(60) sy-uline.
WRITE:/ sy-vline, 'No Of Records Uploded Successfully are: ' COLOR
COL_POSITIVE ,50 srec LEFT-JUSTIFIED,46 sy-vline,60 sy-vline.
WRITE:/(60) sy-uline.
* Function to create error file.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = 'C:\ERRORS.TXT'
filetype = 'DAT'
TABLES
data_tab = it_err.
* Subroutine for bdc_dynpro.
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
* Subroutine for bdc_field.
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
* Subroutine for bdc_transaction.
FORM bdc_transaction USING tcode.
DATA text(74).
DATA text1(34).
DATA text2(20).
text1 = 'Uploading Data for MATERIAL(MAKTX):' .
text2 = '---PLEASE WAIT.'.
CONCATENATE text1 itab-MAKTX text2 INTO text.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = text
EXCEPTIONS
OTHERS = 1.
REFRESH messtab.
CALL TRANSACTION tcode USING bdcdata
MODE 'N'
* MODE 'A'
UPDATE 'S'
MESSAGES INTO messtab.
l_subrc = sy-subrc.
* Moving data to it_trec.
MOVE l_subrc TO it_trec-rtcode.
MOVE itab-line TO it_trec-rec.
MOVE itab-MAKTX TO it_trec-MAKTX.
MOVE itab-MATKL TO it_trec-MATKL.
APPEND it_trec.
* Looping in bdcmsgcoll structure.
LOOP AT messtab.
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 it_trec-mess.
MODIFY it_trec INDEX sy-tabix.
ENDIF.
ENDLOOP.
FORMAT COLOR 4.
* Catching error records from it_trec & moving to it_err.
LOOP AT it_trec WHERE rtcode <> 0.
MOVE-CORRESPONDING it_trec TO it_err.
APPEND it_err.
ENDLOOP.
REFRESH it_trec.
REFRESH bdcdata.
Nikhil.
Edited by: Nikhil Kanegaonkar on May 27, 2009 2:31 PM -
hi frnds
we can handle error in call transaction method by using bdcmsgcoll,
error is handled by system using session method and these errors can be analysed by going to tr sm35 . <b>is there is any way by which i will use session method in my program and all the errors will be written in the o/p of the list.
is this is possible , if so pls give me some sample code</b>
thanks
pankajHi,
check the belwo sample code.
Declaration of local constants
CONSTANTS : lc_tcode TYPE tstc-tcode VALUE 'ME31K',
lc_n TYPE ctu_mode VALUE 'N'.
Declaration of local variables
DATA: lv_msg TYPE string,
lv_subrc LIKE sy-subrc,
lv_opt TYPE ctu_params.
lv_opt-defsize = c_x.
lv_opt-dismode = lc_n.
lv_opt-updmode = c_l.
REFRESH i_messtab.
Call the transaction to create the Purchasing Contracts
CALL TRANSACTION lc_tcode USING i_bdcdata
OPTIONS FROM lv_opt
MESSAGES INTO i_messtab.
MOVE sy-subrc TO lv_subrc.
IF lv_subrc NE 0.
v_err_cnt = v_err_cnt + 1.
IF NOT i_messtab[] IS INITIAL.
READ TABLE i_messtab WITH KEY msgtyp = 'E'.
IF sy-subrc EQ 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = i_messtab-msgid
lang = sy-langu
no = i_messtab-msgnr
v1 = i_messtab-msgv1
v2 = i_messtab-msgv2
v3 = i_messtab-msgv3
v4 = i_messtab-msgv4
IMPORTING
msg = lv_msg.
MOVE: p_wa_header-lifnr TO wa_error-lifnr,
p_wa_header-evart TO wa_error-evart,
p_wa_header-vedat TO wa_error-vedat,
p_wa_header-ekorg TO wa_error-ekorg,
p_wa_header-ekgrp TO wa_error-ekgrp,
p_wa_header-epstp TO wa_error-epstp,
p_wa_header-knttp TO wa_error-knttp,
p_wa_header-bukrs TO wa_error-bukrs,
p_wa_header-kdatb TO wa_error-kdatb,
p_wa_header-kdate TO wa_error-kdate,
p_wa_header-ktwrt TO wa_error-ktwrt,
p_wa_header-waers TO wa_error-waers,
p_wa_header-wkurs TO wa_error-wkurs,
p_wa_header-inco1 TO wa_error-inco1,
p_wa_header-inco2 TO wa_error-inco2,
p_wa_header-ihran TO wa_error-ihran,
p_wa_header-angnr TO wa_error-angnr,
lv_msg TO wa_error-msg.
APPEND wa_error TO i_error.
CLEAR wa_error.
ELSE.
READ TABLE i_messtab WITH KEY msgtyp = 'S'.
IF sy-subrc EQ 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = i_messtab-msgid
lang = sy-langu
no = i_messtab-msgnr
v1 = i_messtab-msgv1
v2 = i_messtab-msgv2
v3 = i_messtab-msgv3
v4 = i_messtab-msgv4
IMPORTING
msg = lv_msg.
ENDIF.
ENDIF.
ENDIF.
ELSE.
v_cnt = v_cnt + 1.
ENDIF.
REFRESH i_bdcdata.
*& Form prepare_field_catalog
Prepare Field catalog
<--P_I_FIELDCAT[] Internal table for Field Catalog
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE t_fieldcat.
Declaration of local workarea
DATA: lwa_fieldcat TYPE slis_fieldcat_alv.
Declaration of local constants
CONSTANTS : lc_long_text(1) TYPE c VALUE 'L'.
*--Call the functino module to get the field catalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'I_SUCCESS'
i_inclname = sy-repid
CHANGING
ct_fieldcat = pt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
LOOP AT pt_fieldcat INTO lwa_fieldcat.
CASE lwa_fieldcat-fieldname.
WHEN 'VEDAT'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-004.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'KDATB'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-005.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'KDATE'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-006.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
WHEN 'IHRAN'.
lwa_fieldcat-ddictxt = lc_long_text.
lwa_fieldcat-seltext_l = text-007.
MODIFY i_fieldcat FROM lwa_fieldcat
INDEX sy-tabix TRANSPORTING ddictxt seltext_l .
CLEAR lwa_fieldcat.
ENDCASE.
ENDLOOP. "LOOP AT pt_fieldcat INTO lwa_fieldcat.
ENDIF. "IF sy-subrc <> 0
ENDFORM. " prepare_field_catalog
*& Form display_output
To display the success contracts output in ALV
FORM display_output .
Declaration of local workarea
DATA : lwa_layout TYPE slis_layout_alv.
Declaration of local constants
CONSTANTS : lc_chk(1) TYPE c VALUE 'X',
lc_page TYPE slis_formname VALUE 'SUB_TOP_OF_PAGE'.
Subroutine to prepare the Field Catalog
PERFORM prepare_field_catalog CHANGING i_fieldcat[].
Subroutine to build layout
lwa_layout-box_tabname = 'I_SUCCESS'.
lwa_layout-no_input = lc_chk.
lwa_layout-colwidth_optimize = lc_chk.
lwa_layout-zebra = lc_chk.
lwa_layout-cell_merge = lc_chk.
FM to call the ALV Grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_bypassing_buffer = c_x
i_callback_top_of_page = lc_page
is_layout = lwa_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = i_success
EXCEPTIONS
program_error = 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.
ENDFORM. " display_output
Rewrad if helpful.
Regards,
Nagaraj -
Call transaction and session methods error records
Hi All,
In call transaction method we will define a table of type bdcmsgcoll for storing the error records and later we will display that error message with format_message.In that table only those records with message type 'E' are stored or any other ?
I mean while transferring data using BDC either by call transaction or session method ,if we got message type other than 'E', like W or A etc.what about those records ,they will be udpated sucessfully or not?which message type records will be stored in the error log or in bdcmsgcoll table.
Thanks,
Rakesh.You will get all type of message recorded in the BDCMSGCOLL table when you use the CALL Transaction
For Session mehtod, while running you need to tick the "Extended Log" checkbox on the popup which comes after the process button.
Regards,
Naimesh Patel -
Call transaction and session method error
hi,
suppose i have 100 records, there is an error in 91 record, then my doubt is up to 90 records data is process to database or not?
Please clear doubt
1. if it is call transaction,
2.if it is session method.hi,
in session method if u go for fore ground process it will process record by record
suppose if error record is entered it doesnt proceed further, u had to enter correct record
then it allows u to proceed furtherafter procesing all the records it asks u to save
then all records get stored uin data base tables.
suppose if u go for back ground process in error mode,
all the records get processed, except the error record.
in call transaction,
wen ever error record occurs it wont proceed further untill correct record is entered,
finally all the records is processed it will ask u to save then only records get saved in data base.
regards
siva -
Errors in Call transaction and Session method.
Hi all
Please explain me in detail with example how to handle errors in call transaction method and session method.
Thanks in advance
Manu.Hi,
In Session Method Datawill be stored in session.In that session u can find error recods.
In CALL Transation useing 'FORMAT_MESSAGE' Function Module u can catch the errors.
ex:
LOOP AT it_messtab.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = it_messtab-msgid
lang = it_messtab-msgspra
no = it_messtab-msgnr
v1 = it_messtab-msgv1
v2 = it_messtab-msgv2
IMPORTING
msg = g_msg
EXCEPTIONS
OTHERS = 0.
IF it_messtab-msgtyp = 'S'.
it_sucess-sucess_rec = g_msg.
it_sucess-lifnr = it_header-lifnr." Based on your field
it_sucess-tabix = v_lines.
APPEND it_sucess.
ELSEIF it_messtab-msgtyp = 'E'.
it_error-error_rec = g_msg.
it_error-lifnr = it_header-lifnr.
it_error-tabix = v_lines.
APPEND it_error.
ELSE.
it_info-info_rec = g_msg.
it_info-lifnr = it_header-lifnr.
it_info-tabix = v_lines.
APPEND it_info.
ENDIF.
ENDLOOP.
LOOP AT IT_BDC_MESSAGES.
IF IT_BDC_MESSAGES-msgtyp = 'E'.
SELECT single * FROM t100 WHERE
sprsl = it_BDC_MESSAGES-msgspra
AND arbgb = IT_BDC_MESSAGES-msgid
AND msgnr = IT_BDC_MESSAGES-msgnr.
IF sy-subrc = 0.
l_mstring = t100-text.
IF l_mstring CS '&1'.
REPLACE '&1' WITH IT_BDC_MESSAGES-msgv1 INTO l_mstring.
REPLACE '&2' WITH IT_BDC_MESSAGES-msgv2 INTO l_mstring.
REPLACE '&3' WITH IT_BDC_MESSAGES-msgv3 INTO l_mstring.
REPLACE '&4' WITH IT_BDC_MESSAGES-msgv4 INTO l_mstring.
ELSE.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv1 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv2 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv3 INTO l_mstring.
REPLACE '&' WITH IT_BDC_MESSAGES-msgv4 INTO l_mstring.
ENDIF.
CONDENSE l_mstring.
it_mess-msgtyp = IT_BDC_MESSAGES-msgtyp.
it_mess-lms = l_mstring.
it_mess-msgv1 = IT_BDC_MESSAGES-msgv1.
APPEND it_mess.
ELSE.
it_mess-msgtyp = IT_BDC_MESSAGES-msgtyp.
it_mess-lms = l_mstring.
it_mess-msgv1 = IT_BDC_MESSAGES-msgv1.
APPEND it_mess.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
Reward if useful.
Regards,
Narasimha -
How to handile errors in batch input(session)method
Hi Friends..
How to <b>Re upload the error records</b> in batch input(session)method in BDC Programming?
Regards
D BabuHi
U can do it manually by SM35: the wrong trxs can be run again.
If you want to do automatically I don't think you can do it easyly, because to know if a record was loaded successfully depends on how you have loaded it and your data source .
For example:
if the records have to be loaded are from a file and every record is a trx, you could re-read the file and match it with session log:
Log--Result--
Record file
Trx 1 OK 1
Trx 2 OK 2
Trx 3 KO 3 (Re-load it)
Trx 4 OK 4
Trx 5 KO 5 (Re-load it)
Trx 6 OK 6
How to read session log see trx sm35
Max -
Listing BDC session method error records
Hi ABAP'rs,
Can any one help me, how to show error records of BDC session method on the List screen.
Thanks and Regards,
Param.Hi,
goto sm35 and find the error logs.
what do you mean by list screen...do you mean in ort output ?
Regards,
pankaj singh -
Session method and call transaction methos which one is the sap recomonded
hi
PLease give me the answer to these questions.
session method and call transaction methos which one is the sap recomonded why .
2) if we want to maintain BDC program in all the systems.wt to d0Hi Revethi,
Here is the difference between the Session and Call Transaction method.
Session
Session method supports both small amount of data aswell as large amount of data
2) data processing is asynchronus and data updation is synchronus.
3) it process multiple apllication while perfomaning validations.
4) in session method data will be updated in data base only after processing session only.
5) system provide by default logfile for handling error records.
6) it supports both foreground aswell as background process
in bdc we use FM ... bdc_open_group " for creating Session
bdc_insert " adding transaction and bdcdata table for updating database
bdc_close_group " for closing Session
Call Transaction
Call transaction exclusively for small amout of data
2) it supports only one apllication while perfoming validations
3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
we can create logfile by using structure....BDCMSGCOLL
4) it doesn't support background processing.
5) data processing is synchronous and Data updation is Synchronous( default), in
this method also supports daya updation in asynchronus process also.
Syntax:
Call transaction <transaction-name> using BDCDATA
mode <A/N/E> update <L/A/S>
messages into BDCMSGCOLL.
Maybe you are looking for
-
sometimes they come in a zip file, which I really don't know what to do with, so I have unzipped it to a picture folder which leaves an entire folder within a folder. That also leaves an empty zip folder in my pictures. The craziest thing and most un
-
Editing or Deleting a Contact in 8500 series
I am having trouble with one particular contact whereby I am unable to delete or edit their information. When editing and then trying to save I get the following message: "Contact updated externally. Changes will be lost and the viewer closed." HELP
-
Older version of Youveiw box delivered
Hi. I have been on the phone since 1300 as my new Youviewbox was delivered today, but having been promised by BT and sent documents about their latest BT Youview box, what arrived was an older version. This is grey type not black version. Also it is
-
Hi , Is there any option to have flexibility to select fields for output in the selection screen.please help me. Thanks, Hari
-
How to get the highest point of the taskbar
I would like to show a JWindow just above taskbar. How can I get the highest point of the taskbar? Is there a way like System.getProperty("os.taskbarHeight") ? In MS windows the taskbar has standard height but in KDE the taskbar has variable height (