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

Displaying Confirmation Message after a Background Session Create

Former Member
0 Likes
1,740

Hi All,

I have an application that creates a financial document in a background session. I want to wait for this background session to complete and then display to the user that it has completed and what the document number is.

How can I do this?

Currently I am waiting 5 seconds and then displaying the newest document that has been added to BKPF but I know that this is probably not very good practice. I was hoping there was a better way.

Thanks for any help, its much appreciated,

Colm

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,698

Hi Colm,

Are you creating the session and processing the session in the same program?

If you are using call transaction, then you could have specified the UPDATE = 'S' to get the document number immediately after the call to the transaction by writing the select statement.

Or else, you can look for the success messages in a mesages table using the call trasnaction method

call transaction <TCode> using it_bdcdata messages into it_bdcmsgcoll.

if sy-subrc = 0.

loop at it_bdcmsgcoll where msgtyp = 'S'.

  • look in IT_BDCMSGCOLL-msgv1 msgv2 msgv3 or msgv4 to get the document that has been created just then.

endloop.

endif.

Regards,

Ravi

16 REPLIES 16
Read only

Former Member
0 Likes
1,699

Hi Colm,

Are you creating the session and processing the session in the same program?

If you are using call transaction, then you could have specified the UPDATE = 'S' to get the document number immediately after the call to the transaction by writing the select statement.

Or else, you can look for the success messages in a mesages table using the call trasnaction method

call transaction <TCode> using it_bdcdata messages into it_bdcmsgcoll.

if sy-subrc = 0.

loop at it_bdcmsgcoll where msgtyp = 'S'.

  • look in IT_BDCMSGCOLL-msgv1 msgv2 msgv3 or msgv4 to get the document that has been created just then.

endloop.

endif.

Regards,

Ravi

Read only

Sougata
Active Contributor
0 Likes
1,698

Please look at program RSBDCSUB and command

SUMBIT program AND RETURN EXPORTING LIST TO MEMORY (from the top of my head). Then fire FM to read the list exported which will have the doc number.

Read only

Former Member
0 Likes
1,698

I am actually using SUMBIT program AND RETURN EXPORTING LIST TO MEMORY.

So I will use the function module. What is the function module name that I should use?

Thanks again,

Colm

Read only

Sougata
Active Contributor
0 Likes
1,698

Use FM 'LIST_FROM_MEMORY' and then there is another FM availble to read the list or I think you can loop at the table returned to read it (sorry, Im not in front of SAP right now). Can you please reward points or I'll stop helping you in future!

Read only

Former Member
0 Likes
1,698

When I look at the table in debug mode after calling FUNCTION 'LIST_FROM_MEMORY' I get 4 entries that look like this:

101000801010101010100000101010300040000020301030106000B010100000100010000

Am I calling it incorrectly or is there a special way of reading the table?

Thanks,

Colm

Read only

Sougata
Active Contributor
0 Likes
1,698

sorry, can't help anymore without any reward...yawn....

Read only

Former Member
0 Likes
1,698

I have already awarded you points?

Read only

Sougata
Active Contributor
0 Likes
1,698

now we are talking

look for FM READLIST and pass your itab (abaplist) to read it. currently its in a different format. after conversion it will make sense thus you'll get doc number returned.

Read only

Former Member
0 Likes
1,698

When I do the search for the FM I get the below list, however none of them appear to be passed a table?

READ_EXT_OBJLIST

READ_MRP_LIST

READ_G_LISTED

READ_LAYMOD_LISTING

Read only

Sougata
Active Contributor
0 Likes
1,698

Try this:


    SUBMIT RSBDCSUB WITH SELECTION......etc etc....
       EXPORTING LIST TO MEMORY AND RETURN.

    CALL FUNCTION 'LIST_FROM_MEMORY'
         TABLES
              listobject = li_listobject
         EXCEPTIONS
              not_found  = 1
              OTHERS     = 2.

  IF sy-subrc = 0.

    CALL FUNCTION 'WRITE_LIST'
         TABLES
              listobject = li_listobject
         EXCEPTIONS
              empty_list = 1
              OTHERS     = 2.
    IF sy-subrc <> 0.
      write:/ 'List could not be read'.
    ELSE.
      LOOP AT li_listobject.
* read what you are looking for here 
      ENDLOOP.    
    ENDIF.
 ELSE.
  write:/ 'No list was found in memory'.
 ENDIF.

Read only

Sougata
Active Contributor
0 Likes
1,698

if the list still cannot be read try with FM 'LIST_TO_ASCI'.

Good luck.

Read only

Former Member
0 Likes
1,698

OK FM WRITE_LIST didn't work but thankfully LIST_TO_ASCI does!

However it still doesn't provide me with a document number. It does provide me with a Queue ID number though, is there any way to derive the document number using the Queue ID?

The table produces:

|Time |Session |Date |Time |Job no. |Queue ID

|--


|
|

|

|

|
--


|14:51:08 |JE_TRAD |11.04.2007|14:51:06|14510701 |0704111451065

Read only

Sougata
Active Contributor
0 Likes
1,698

you have to read the BDC log using the Queue ID. I dont remember the name of the table...do a F1/F9 on SM35 BDC session name...something like APQ? comes to mind. but the log may be stored in a different table or better use a FM to read the BDC log where it will have the document number stored for every transaction.

why use this BDC? why not use a BAPI....a BAPI will always have doc number in one of the returrn parameter/table and its much easier to use!

its midnight here so i'll try to do a bit of shut-eye now, but do leave me a note if you managed to make it work....good luck, you'll need it mate! )

Read only

Sougata
Active Contributor
0 Likes
1,698

another idea is to change the BDC code to use CALL TRANSACTION MESSAGES INTO itab. if doc posting is successful, itab will have the doc number which can be retrieved by reading the itab. you can also check the itab for docs that didnt post and then insert these transactions into a BDC error session. just a thought.

Read only

Former Member
0 Likes
1,698

OK we have decided that this poblem is too time consuming and that we need to move on. I will come back to this later to see if there is a way to solve it. Thanks for your help anyway

Read only

Former Member
0 Likes
1,698

This message was moderated.