Skip to Content
0
Former Member
Mar 20, 2009 at 11:36 PM

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

155 Views

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