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: 

Retaining the selected tab in a tabbed block of selection screen

Former Member

Hi,

My report has a selection screen with a tabbed block displaying 3 tabs. I want to retain the tab that was selected before executing the report and display that tab as the activetab when the user back navigates from the output list of the report to the selection screen.

I tried to store the value of 'activetab' component of the tabbed block in a global variable and assigned the global variable to the 'activetab' component. But it is not working.

Is there any other way by which we can do this?

Thanks and Regards,

Tongston

1 ACCEPTED SOLUTION

Rashid_Javed
Contributor

I had a similar problem some time ago. One clarification first, global variables will not work because when you come back from report output, all the global/local variables are initialized that is when you come back to selection screen from report output, it is like a new instance of report.

To resolve this you can use Export to memory ID / Import from memory ID statements, as these will retain the data across report instances.

Now the following code is doing exactly what you wanted. You should copy/ paste it in an abap program and run it to see for yourself how I retained active tab. Hope this will help you.

REPORT yy_test002.

TABLES: bkpf, bseg, glt0, fdes, lfa1.

DATA: g_acttab(132) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.

PARAMETERS: p_bukrs LIKE bkpf-bukrs, "obligatory,

p_upto LIKE bkpf-budat.

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon1 FOR bseg-hkont NO-EXTENSION,

s_lifn1 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 101.

SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon2 FOR bseg-hkont NO-EXTENSION,

s_lifn2 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 102.

SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon3 FOR bseg-hkont NO-EXTENSION,

s_lifn3 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 103.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME.

PARAMETERS: p_dued LIKE bseg-fdtag.

SELECTION-SCREEN BEGIN OF TABBED BLOCK tbblk FOR 8 LINES.

SELECTION-SCREEN TAB (18) tabname1

USER-COMMAND 'UTB1' DEFAULT SCREEN 101.

SELECTION-SCREEN TAB (18) tabname2

USER-COMMAND 'UTB2' DEFAULT SCREEN 102.

SELECTION-SCREEN TAB (18) tabname3

USER-COMMAND 'UTB3' DEFAULT SCREEN 103.

SELECTION-SCREEN END OF BLOCK tbblk.

SELECTION-SCREEN END OF BLOCK blk2.

INITIALIZATION.

tabname1 = 'GL Accounts set 1'.

tabname2 = 'GL Accounts set 2'.

tabname3 = 'GL Accounts set 3'.

IMPORT g_acttab FROM MEMORY ID 'zssfsdfr3'.

IF sy-subrc = 0.

tbblk-prog = sy-repid.

tbblk-activetab = g_acttab.

CASE g_acttab.

WHEN 'UTB1'.

tbblk-dynnr = 101.

WHEN 'UTB2'.

tbblk-dynnr = 102.

WHEN 'UTB3'.

tbblk-dynnr = 103.

WHEN OTHERS.

ENDCASE.

ENDIF.

START-OF-SELECTION.

g_acttab = tbblk-activetab.

EXPORT g_acttab TO MEMORY ID 'zssfsdfr3'.

WRITE:/ 'current active tab:', g_acttab.

WRITE:/ 'bye'.

RJv
4 REPLIES 4

Rashid_Javed
Contributor

I had a similar problem some time ago. One clarification first, global variables will not work because when you come back from report output, all the global/local variables are initialized that is when you come back to selection screen from report output, it is like a new instance of report.

To resolve this you can use Export to memory ID / Import from memory ID statements, as these will retain the data across report instances.

Now the following code is doing exactly what you wanted. You should copy/ paste it in an abap program and run it to see for yourself how I retained active tab. Hope this will help you.

REPORT yy_test002.

TABLES: bkpf, bseg, glt0, fdes, lfa1.

DATA: g_acttab(132) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.

PARAMETERS: p_bukrs LIKE bkpf-bukrs, "obligatory,

p_upto LIKE bkpf-budat.

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon1 FOR bseg-hkont NO-EXTENSION,

s_lifn1 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 101.

SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon2 FOR bseg-hkont NO-EXTENSION,

s_lifn2 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 102.

SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN.

SELECT-OPTIONS: s_hkon3 FOR bseg-hkont NO-EXTENSION,

s_lifn3 FOR bseg-lifnr.

SELECTION-SCREEN END OF SCREEN 103.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME.

PARAMETERS: p_dued LIKE bseg-fdtag.

SELECTION-SCREEN BEGIN OF TABBED BLOCK tbblk FOR 8 LINES.

SELECTION-SCREEN TAB (18) tabname1

USER-COMMAND 'UTB1' DEFAULT SCREEN 101.

SELECTION-SCREEN TAB (18) tabname2

USER-COMMAND 'UTB2' DEFAULT SCREEN 102.

SELECTION-SCREEN TAB (18) tabname3

USER-COMMAND 'UTB3' DEFAULT SCREEN 103.

SELECTION-SCREEN END OF BLOCK tbblk.

SELECTION-SCREEN END OF BLOCK blk2.

INITIALIZATION.

tabname1 = 'GL Accounts set 1'.

tabname2 = 'GL Accounts set 2'.

tabname3 = 'GL Accounts set 3'.

IMPORT g_acttab FROM MEMORY ID 'zssfsdfr3'.

IF sy-subrc = 0.

tbblk-prog = sy-repid.

tbblk-activetab = g_acttab.

CASE g_acttab.

WHEN 'UTB1'.

tbblk-dynnr = 101.

WHEN 'UTB2'.

tbblk-dynnr = 102.

WHEN 'UTB3'.

tbblk-dynnr = 103.

WHEN OTHERS.

ENDCASE.

ENDIF.

START-OF-SELECTION.

g_acttab = tbblk-activetab.

EXPORT g_acttab TO MEMORY ID 'zssfsdfr3'.

WRITE:/ 'current active tab:', g_acttab.

WRITE:/ 'bye'.

RJv

0 Kudos

Hi Rashid,

Thanks for the reply. But i can't use Memory ID to store the active tab since the report can be used simultaneously by different users and the Memory ID get overwritten every time.

Thanks and Regards,

Tongston.

0 Kudos

Memory ID is session specific for each user. Each user running the program will save memory id in its individual program space. It doesn't overwrite other users memory!!!!

It is quite well known fact. Even than i suggest you check SAP ABAP help for commands "EXPORT to memory ID" and "IMPORT from memory ID". It is pretty clearly written there that data cluster is written to abap memory which is session Dependant.

RJv

0 Kudos

Yes Rashid. You are right. I was a bit confused by the ABAP keyword documentation for EXPORT TO MEMORY ID.

Now it works.....

Thanks a lot...

Regards,

Tongston