2015 Mar 17 1:57 PM
Hi Experts
I have a ABAP BDC code which calls VL01N0 (create delivery note).
When there is an error for mandatory fields that is, "Enter all required fields" I want to get the exact field name.
I tried GET CURSOR FIELD v_fld but it it does not return an value in v_fld.
What am i doing wrong? Is there any other alternative solution?
Thanks
Gopal
2015 Mar 17 4:05 PM
Hi,
Try,
DATA it_msg TYPE TABLE OF bdcmsgcoll,
wa_msg LIKE LINE OF it_msg,
v_text(100) TYPE c.
CALL TRANSACTION 'VL01N' USING it_bdcdata
MODE ctumode " 'N'
UPDATE 'A'
MESSAGES INTO it_msg.
IF sy-subrc <> 0.
LOOP AT it_msg INTO wa_msg.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = wa_msg-msgid
lang = sy-langu
no = wa_msg-msgnr
v1 = wa_msg-msgv1
v2 = wa_msg-msgv2
v3 = wa_msg-msgv3
v4 = wa_msg-msgv4
IMPORTING
msg = v_text
EXCEPTIONS
not_found = 1
OTHERS = 2.
.
Append the v_text to internal table, display in ALV or classical.
Hope it helpful,
Regards,
Venkat.
2015 Mar 17 4:09 PM
For testing purposes, you can use mode 'E' with statement CALL TRANSACTION and run in foreground mode.
This will stop and show the screen where error occured. You can then see which field caused the error.
2015 Mar 17 4:15 PM
I don't think this is possible. And if it were, what would you do if there were more than one field missing.
You can use CALL TRANSACTION with MODE 'E', so that at least processing stops when an error is encountered. Like Saurabh Shukla said
Rob
Message was edited by: Rob Burbank
2015 Mar 18 2:57 AM
Hi Gopal,
Instead of using BDC in the background, please use Standard BAPI to achieve this. Because BDC intended to use in the foreground.
Indra
2015 Mar 18 4:33 AM
Hi,
You can get field name from MESSAGETAB of CALL Transaction even in background mode. So try to read message tab after call transaction method if sy-subrc <> 0. It will work even in background also.
CALL TRANSACTION 'VL01N' USING gt_bdcdata MESSAGES INTO gt_messtab...