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: 

How to get cursor position on a field in background mode?

gopalkrishna_baliga
Participant
0 Kudos
141

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

5 REPLIES 5

VenkatRamesh_V
Active Contributor
0 Kudos
95

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.

Former Member
0 Kudos
95

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.

Former Member
0 Kudos
95

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

indra_dewaji
Explorer
0 Kudos
95

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

Former Member
0 Kudos
95

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