cancel
Showing results for 
Search instead for 
Did you mean: 

errors in call transaction

Former Member
0 Kudos

hii frnds plz help me with the folowing code for trapping errrors in call transaction .

loop at messtab.

move-corresponding messtab to messages.

call function 'FORMAT_MESSAGE'

exporting

id = messtab-msgid

lang = messtab-msgspra

no = messtab-msgnr

v1 = messtab-msgv1

v2 = messtab-msgv2

v3 = messtab-msgv3

v4 = messtab-msgv4

importing

msg = messages-text

exceptions

not_found = 01

others = 02.

if sy-subrc <> 0.

clear messages-text.

endif.

append messages.

endloop.

open dataset w_physical_file for output in text mode.

loop at messages..

transfer messages to w_physical_file.

endloop.

close dataset w_physical_file.

i wanted to ask that the file w_physical_file is actualy holding all the errors on our sequential file or not . and suppose i have got 500 errors out of 1000 records then how should i correct the errors and modify our sequential file . i mean to say do i have to do it maualy correcting all the 500 errors in the w_physical_file and modify my sequential file . plz help as i am confused with the error handling in call transaction .

Accepted Solutions (1)

Accepted Solutions (1)

hymavathi_oruganti
Active Contributor
0 Kudos

w_physical_file contains all the erroneous records.

display that file as a list and u need to manually correct the records and prepare a new file and again do the call transaction. no other go.

Former Member
0 Kudos

I think the file only contains the messages, without indicating which record caused the problem. It will just say something like "Invalid company code ZZZZ".

Rob

Answers (7)

Answers (7)

Former Member
0 Kudos

hii could u plz specify the handling of errors in session method . i mean if i have got about 500 errors in session log then how could i process the errors and modify the file .

Former Member
0 Kudos

hi frnds thanks for ur reply

i wanted to know that how could i display th errors using w_physical_file. and how can access the file in the application server

abdul_hakim
Active Contributor
0 Kudos

hi gupta,

i would advice you to create a session for your incorrect transaction rather than going in other way.

Since the error handling could be very easy with the session method.......

Cheers,

Abdul Hakim

Former Member
0 Kudos

Hai Rohit

Check the following Code

it will solved your problem

      • Generated data section with specific formatting - DO NOT CHANGE ***

data: begin of it_lfa1 occurs 0,

KTOKK like lfa1-ktokk,

NAME1 like lfa1-name1,

SORTL like lfa1-sortl,

LAND1 like lfa1-land1,

end of it_lfa1.

      • End generated data section ***

data : it_bdc like bdcdata occurs 0 with header line.

*DATA: IT_MESSAGES TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.

*DATA: LV_MESSAGE(255).

data : it_messages like bdcmsgcoll occurs 0 with header line.

data : V_message(255).

data : V_flag.

data : V_datum1 type sy-datum.

data : begin of it_mesg occurs 0,

message(100),

end of it_mesg.

*V_datum1 = sy-datum-1.

parameters : P_Sess like APQI-GROUPID.

start-of-selection.

perform Get_data.

*perform open_group.

loop at it_lfa1.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-KTOKK'

it_lfa1-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-LAND1'.

perform bdc_field using 'BDC_OKCODE'

'=UPDA'.

perform bdc_field using 'LFA1-NAME1'

it_lfa1-name1.

perform bdc_field using 'LFA1-SORTL'

it_lfa1-sortl.

perform bdc_field using 'LFA1-LAND1'

it_lfa1-land1.

call transaction 'XK01' using it_bdc

mode 'N'

update 'S'

messages into it_messages.

if sy-subrc <> 0.

if V_flag <> 'X'.

perform open_group.

V_flag = 'X'.

endif.

perform bdc_transaction. "using 'XK01'.

endif.

perform format_messages.

refresh : it_bdc,it_messages.

.

endloop.

if V_flag = 'X'.

perform close_group.

endif.

&----


*& Form Get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM Get_data .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\srinu_vendor.txt'

FILETYPE = 'ASC'

TABLES

DATA_TAB = it_lfa1

EXCEPTIONS

CONVERSION_ERROR = 1

INVALID_TABLE_WIDTH = 2

INVALID_TYPE = 3

NO_BATCH = 4

UNKNOWN_ERROR = 5

GUI_REFUSE_FILETRANSFER = 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.

ENDFORM. " Get_data

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0061 text

  • -->P_0062 text

----


FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR it_BDC.

it_BDC-PROGRAM = PROGRAM.

it_BDC-DYNPRO = DYNPRO.

it_BDC-DYNBEGIN = 'X'.

APPEND it_BDC.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR it_BDC.

it_BDC-FNAM = FNAM.

it_BDC-FVAL = FVAL.

APPEND it_BDC.

ENDFORM.

&----


*& Form format_messages

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM format_messages .

loop at it_messages.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = it_messages-MSGID

LANG = 'EN'

NO = it_messages-MSGNR

V1 = it_messages-MSGV1

V2 = it_messages-MSGV2

V3 = it_messages-MSGV3

V4 = it_messages-MSGV4

IMPORTING

MSG = V_message

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.

write : / V_message.

clear : V_message.

endloop.

ENDFORM. " format_messages

&----


*& Form open_group

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM open_group .

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

GROUP = P_Sess

  • HOLDDATE = V_datum1

KEEP = 'X'

USER = SY-UNAME

.

IF SY-SUBRC = 0.

write : / 'Session Creating wit Name : ',P_Sess.

ENDIF.

ENDFORM. " open_group

&----


*& Form close_group

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM close_group .

CALL FUNCTION 'BDC_CLOSE_GROUP'.

ENDFORM. " close_group

&----


*& Form bdc_transaction

&----


  • text

----


  • -->P_0132 text

----


FORM bdc_transaction. "USING VALUE(P_0132).

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'XK01'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

DYNPROTAB = it_bdc

  • 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.

ENDFORM. " bdc_transaction

Thanks & regards

Sreenivasulu P

former_member186741
Active Contributor
0 Kudos

as Rob has suggested, if you add a 'record number' field to your 'messages' table definition (and populate this after call transaction) you will be able to identify which input records the various messages belong to.

Reprocessing them is another matter.... can you fix the bad records and reinput the whole file? Maybe you can't as the 'good' records might now fail.... maybe you can?? If not you'll need to create a new input file of only the editted bad records and then process that.

Former Member
0 Kudos

Your file w_physical_file will contain all your error messages, but it won't be enough to correct errors in your input file. For each record in w_physical_file, you need some sort of indicator to tell which record is in error. For example, if the tenth input record is an error, you need a '10' on the error record. Each input record may produce any number of messages in messtab.

If you want to be able to correct the errors, you should write the input record that caused the error to a separate output file that has only input records that caused an error. This file can then be corrected and resubmitted.

Rob

Former Member
0 Kudos

plz give some method by using call transaction only

Former Member
0 Kudos

Hi Rohit,

Use both <b>call transaction and session method </b>combinely ...i.e, with call transaction post the records and with session method in 'A' mode correct those records which contains errors ....

Regards,

Santosh