Application Development and Automation 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: 
Read only

Call Transaction

Former Member
0 Likes
1,180

Hello,

How do you recover a key that was generated during a call transaction. Specifically, I ran IW31 via call transaction (as opposed to batch input). After the execution I tried to get the generated work order number using GET PARAMETER ID 'ANR'. I got a return code of 4. It seems that GET PARAMETER ID is not the correct way to get the generated key. HOW then?

Thanks in advance.

mki

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,115

hi ,

CALL TRANSACTION XXXX

USING BDCDATA

MESSAGES INTO MESSTAB

MODE N.

Here you will get all the messages. Then do like this,

go to debugging mode there you will find message id and message number for successful message and error messages.

take that sucessful message and message id and do like this

READ TABLE MESSATAB INTO WA_MESSTAB WITH KEY MSGID = 'message id' MSGNR = 'message no'.

Then Document Number = WA_MESSTAB-MSGV1.

I Hope it will work.

Regards

Rami Reddy

Hello,

How do you recover a key that was generated during a call transaction. Specifically, I ran IW31 via call transaction (as opposed to batch input). After the execution I tried to get the generated work order number using GET PARAMETER ID 'ANR'. I got a return code of 4. It seems that GET PARAMETER ID is not the correct way to get the generated key. HOW then?

Thanks in advance.

mki

9 REPLIES 9
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,115

Hi,

Did you use SET PARAMTER ID before using CALL TRANSACTION ?

Regards,

Tarun

Read only

RahulKeshav
Active Contributor
0 Likes
1,115

why dont u collect the BDC message after call transaction....

it will contain the document no. genrated.

please try....

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,115

Try with Function Module ABAP4_CALL_TRANSACTION

Read only

Former Member
0 Likes
1,115

Hi,

Collect the messages from the BDC and find out the success message class and number being used. You should be able to get the number in one of the variables.

Thanks

Saachin

Read only

Former Member
0 Likes
1,115

HI ,

When u call the transaction at that time u can colllect the message into an internal table and then u will get the work order number

in internal table.

first u declare internal table

data: itab type standard table of BDCMSGCOLL .

call transaction " Trans name "

MESSAGES INTO itab

Thanks

shambhu

Read only

Former Member
0 Likes
1,115

Hi,

In this with the CALL TRANSACTION statement,

you can include BDCMSGCOLL Structure also like:



data itab like bdcmsgcoll.
*.CALL TRANSACTION (Tcode Name).. { {[MODE mode] [UPDATE upd]} 
    | [OPTIONS FROM opt] } 
    [MESSAGES INTO itab] ... .*

if sy-subrc = 0.

* use FORMAT_MESSAGE to read the complete description of message
* based on the message-id (msgid) and message-number(msgnr)
  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id        = messtab-msgid
      lang      = sy-langu
      no        = messtab-msgnr
*          v1        = messtab-msgv1   
*          v2        = messtab-msgv2    "In one of these variables your work order will get captured
*          v3        = messtab-msgv3
*          v4        = messtab-msgv4
    IMPORTING
      msg       = wa_message-msg
    EXCEPTIONS
      not_found = 1
      OTHERS    = 2.

  IF sy-subrc <> 0.
    MOVE w_aufnr TO wa_message-aufnr.
    APPEND wa_message TO it_message.   "Final Internal table
  ELSE.
    MOVE w_aufnr TO wa_message-aufnr.
    APPEND wa_message TO it_message.
  ENDIF.
endif.

Hope it helps

Regards

Mansi

Read only

Former Member
0 Likes
1,115

Hi,

Please use MESSTAB internal table for call transaction. You will get the document number as the last line of the internal table.

Use below code -

CALL TRANSACTION XXXX

USING BDCDATA

MESSAGES INTO MESSTAB

MODE N.

This is the correct way getting document data. If the transaction fails you will get the error message/warning messages into this table as well.

Try it,

Thanks,

Vivekanand

Read only

Former Member
0 Likes
1,116

hi ,

CALL TRANSACTION XXXX

USING BDCDATA

MESSAGES INTO MESSTAB

MODE N.

Here you will get all the messages. Then do like this,

go to debugging mode there you will find message id and message number for successful message and error messages.

take that sucessful message and message id and do like this

READ TABLE MESSATAB INTO WA_MESSTAB WITH KEY MSGID = 'message id' MSGNR = 'message no'.

Then Document Number = WA_MESSTAB-MSGV1.

I Hope it will work.

Regards

Rami Reddy

Read only

Former Member
0 Likes
1,115

Thanks to all who responded. They are all very helpful answers. I hope I didn't miss awarding points to anyone. I don't know if all the points are awarded after I clicked on 1 that solved the problem. There were several !!