‎2008 Jul 17 1:16 AM
Hello All:
I need to call a transaction from within a function module.
When the user finishes with the Transaction, control returns to the function. At this point of time I need to know the last button pressed (OK-CODE) in the transaction screen, (Save, Exit, Back, Quit, Enter or something else)
What is the best way to code this?
Thank you,
Fred.
‎2008 Jul 17 7:04 PM
Thank you Amar.
Friends, I need some more help.
Based upon our higher-up instructions, we need to accomplish this (info transfer in-out of dialog programs) using messages (like in BAPIs) rather than memory ids.
I have pasted a sample code from SAPs BAPI.
CALL TRANSACTION 'PR05'
USING BDCDATA
OPTIONS FROM OPTIONS.
IF SY-MSGTY IS INITIAL.
* execution was canceled by the user
PERFORM SET_RETURN USING 'S' '00' 359
SPACE SPACE SPACE SPACE
RETURN.
ELSE.
IF ( SY-MSGTY EQ 'S' )
AND ( SY-MSGID EQ '56' )
AND ( SY-MSGNO EQ 185 ).
* trip sucessful created, tripnumber is in sy-msgv1
TRIPNUMBER = SY-MSGV1.
ELSE.
CLEAR TRIPNUMBER.
ENDIF. As you can notice, the BAPI accesses the message created in the TCode PR05 thro SYST.
I tried very similar, called a (Z)Tcode from a (Z)function and tried to access the messages from the transaction in the function module thro SYST.
MSGTY, MSGID, MSGNO have values but MSGV1->4 values get cleared out in the function.
What am I doing wrong or missing?
Thanks again,
Fred.
‎2008 Jul 17 1:56 AM
Hi Fred,
I assume that transaction you call is a Z program, so you can add some code.
I think you can save OK-CODE value to memory.
Add this code at your User_Command:
export OK_CODE TO MEMORY ID 'OK_CODE_ZXX'.
Add this code at your FM to get ok_code value:
import OK_CODE from memory id 'OK_CODE_ZXX'.
Note:
ZXX is your tcode.
Regards,
‎2008 Jul 17 4:48 AM
Hi
You can use either ABAP memory or SAP memory for this.
ABAP MEMORY: EXPORT OK_CODE TO MEMORY ID 'XYZ'.
SAP MEMORY: SET PARAMETER ID 'XYZ' FIELD <field_name>
GET PARAMETER ID 'XYZ' FIELD <field_name>
Hope this would help you.
Murthy
‎2008 Jul 17 3:02 PM
Thank you Jatra, Murthy. (Yes, it is a Z transaction)
I am wondering if using a memory id is the best/only way to do it.
How consistent can the memory ids be? Supposing there are multiple users looking at the same transaction, will there be separate and independent memory ids? Are the memory ids created per session, per user?
Thank you,
Fred.
‎2008 Jul 17 4:15 PM
that depends on the memory u use.
if u use SAP memory then per user
if ABAP memory then per internal session
with call transaction u have one more internal session, so u can use abap memory with out any prob.
Best regards
Amar
‎2008 Jul 17 6:37 PM
If you absolutely will not use ABAP memory, you may encapsulate your inner z transaction in a Function Module that has a return code [1], [2], [3] etc according as what OK_code was pressed. I, probably would not sweat it.
‎2008 Jul 17 7:04 PM
Thank you Amar.
Friends, I need some more help.
Based upon our higher-up instructions, we need to accomplish this (info transfer in-out of dialog programs) using messages (like in BAPIs) rather than memory ids.
I have pasted a sample code from SAPs BAPI.
CALL TRANSACTION 'PR05'
USING BDCDATA
OPTIONS FROM OPTIONS.
IF SY-MSGTY IS INITIAL.
* execution was canceled by the user
PERFORM SET_RETURN USING 'S' '00' 359
SPACE SPACE SPACE SPACE
RETURN.
ELSE.
IF ( SY-MSGTY EQ 'S' )
AND ( SY-MSGID EQ '56' )
AND ( SY-MSGNO EQ 185 ).
* trip sucessful created, tripnumber is in sy-msgv1
TRIPNUMBER = SY-MSGV1.
ELSE.
CLEAR TRIPNUMBER.
ENDIF. As you can notice, the BAPI accesses the message created in the TCode PR05 thro SYST.
I tried very similar, called a (Z)Tcode from a (Z)function and tried to access the messages from the transaction in the function module thro SYST.
MSGTY, MSGID, MSGNO have values but MSGV1->4 values get cleared out in the function.
What am I doing wrong or missing?
Thanks again,
Fred.
‎2008 Jul 17 7:21 PM
Try this way
CALL TRANSACTION 'PR05' USING BDCDATA
OPTIONS FROM OPTIONS
MESSAGES INTO MESSTAB.
a®
‎2008 Jul 17 11:07 PM
Well, duh! Thanks a®s pointing that for me.
After checking some more I realize that the MSGV1->4 variables were missing bocs the first variable was initial while rest had values. If the first message variable wasnt empty SYST gets filled.
Thanks again,
Fred.
‎2008 Jul 17 11:09 PM