Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Want to run a BDC even if there is an error in the TCode

Former Member
0 Kudos
229

Hi,

In one of the screens in my BDC an error comes (this happens when that transaction is run from command prompt in foreground also). But in the actual transaction after the user sees the error, he is able to continue changing the fields on the screen and post it. However in BDC, as soon as the error comes, the BDC exits and comes back. I would like it to continue, just the way it does during the manual entry, is there a way I can do this?

The Tcode is LT06 and when user enters the Material doc and click on enter the error occurs, but in the manual mode he is able to enter the Destn Bin, storage type etc and continue. However that is not the case with BDC. I also tried using function module L_TO_CREATE_POSTING_CHANGE, but it gives the same error as the screen

FORM create_to USING r_mblnr TYPE mblnr

r_to_lgort TYPE lgort_d

r_sto_bin TYPE lgpla

CHANGING rt_bapi_message TYPE type_t_bapi_message

r_success TYPE c.

DATA: v_mode TYPE c,

wa_bapi_message TYPE bdcmsgcoll.

CLEAR s_bdcdata.

REFRESH t_bdcdata.

PERFORM bdc_dynpro USING 'SAPML02B' '0203'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RL02B-MBLNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RL02B-MBLNR'

r_mblnr.

  • PERFORM bdc_field USING 'RL02B-MJAHR'

  • '2009'.

PERFORM bdc_field USING 'RL02B-DUNKL'

'H'.

PERFORM bdc_dynpro USING 'SAPML03T' '0102'.

PERFORM bdc_field USING 'LTAP-NLTYP'

r_to_lgort.

PERFORM bdc_field USING 'LTAP-NLBER'

'001'. "destn storage section

PERFORM bdc_field USING 'LTAP-NLPLA'

r_sto_bin. "destn storage section

v_mode = 'N'.

CALL TRANSACTION 'LT06'

USING t_bdcdata

MODE v_mode

UPDATE 'S'

MESSAGES INTO t_messtab.

  • IF sy-subrc <> 0.

IF sy-subrc = 0.

LOOP AT t_messtab INTO wa_bapi_message.

APPEND wa_bapi_message TO rt_bapi_message.

EXIT.

  • MESSAGE ID wa_bapi_message-msgid TYPE wa_bapi_message-msgtyp NUMBER wa_bapi_message-msgnr

  • WITH wa_bapi_message-msgv1 wa_bapi_message-msgv2 wa_bapi_message-msgv3 wa_bapi_message-msgv4.

ENDLOOP.

ELSE.

LOOP AT t_messtab INTO wa_bapi_message.

  • MESSAGE ID wa_bapi_message-msgid TYPE wa_bapi_message-msgtyp NUMBER wa_bapi_message-msgnr

  • WITH wa_bapi_message-msgv1 wa_bapi_message-msgv2 wa_bapi_message-msgv3 wa_bapi_message-msgv4.

APPEND wa_bapi_message TO rt_bapi_message.

ENDLOOP.

  • APPEND t_messtab to rt_bapi_message.

ENDIF.

COMMIT WORK AND WAIT.

ENDFORM. "create_to

Thanks for reading

1 ACCEPTED SOLUTION

Former Member
0 Kudos
74

SAP has provided a way to do this:

After the CALL TRANSACTION, you loop through the message table to see if the call was successful. If it was not, you create a background batch input session with the same data. The user can then process this session and correct the errors.

Rob

4 REPLIES 4

former_member156446
Active Contributor
0 Kudos
74

In background its not possible... error message will stop the process.. thinking its should not continue...

Check with you FC if they can control that error or convert it to a warning message...

Former Member
0 Kudos
74

Hi ,

Now as per the transaction an error is prompted only when the compiler interprets it as false on a data field or a combination of them . Now its in the programmers hand to validate the data before submitting it to the screen .. now this validation should cover all scenario's . One point i want to make here is that bdc is nothing but replaying how the user enter's manually for no of records..

i dont know about this tcode LT06 .

//The Tcode is LT06 and when user enters the Material doc and click on enter the error occurs, but in the manual mode he is able to enter the Destn Bin, storage type etc and continue. However that is not the case with BDC.//

you are entering the material doc no in screen 0203 ..use all screen mode and check what is the error prompting if any and in the normal debugging track that error if some user exit is written using sy-binpt with some error message..

did you tried some relavant tcode other than LT06 which can be used for this purpose cause sometimes we have alternate tcodes to run the bdc .. please check on this .

Br,

Vijay.

Former Member
0 Kudos
75

SAP has provided a way to do this:

After the CALL TRANSACTION, you loop through the message table to see if the call was successful. If it was not, you create a background batch input session with the same data. The user can then process this session and correct the errors.

Rob

Former Member
0 Kudos
74

hi, srikrishna,

sniper is right, you need to record the error step using recording.I am not much aware of tcode LT06. first try to validate the input of LT06 from it's table or is there any other logic. if the input is right it should follow the recording whatere you are using but when it is having error it should follow the new recording whatever you have recorded for with error message. I think this will help you. If you have dout please let me know. Thanks.