‎2007 Apr 11 12:36 PM
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
‎2007 Apr 11 12:43 PM
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
‎2007 Apr 11 12:43 PM
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
‎2007 Apr 11 12:43 PM
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.
‎2007 Apr 11 12:52 PM
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
‎2007 Apr 11 12:59 PM
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!
‎2007 Apr 11 2:00 PM
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
‎2007 Apr 11 2:04 PM
‎2007 Apr 11 2:05 PM
‎2007 Apr 11 2:08 PM
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.
‎2007 Apr 11 2:27 PM
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
‎2007 Apr 11 2:40 PM
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.
‎2007 Apr 11 2:45 PM
if the list still cannot be read try with FM 'LIST_TO_ASCI'.
Good luck.
‎2007 Apr 11 2:53 PM
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
‎2007 Apr 11 2:59 PM
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! )
‎2007 Apr 11 3:04 PM
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.
‎2007 Apr 12 10:31 AM
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
‎2010 Oct 21 4:55 PM