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

Using sets in ABAP

0 Likes
4,135

Hi all,

I have created a set using GS01. How can I use sets in my ABAP coding???

Thank you

4 REPLIES 4
Read only

Former Member
0 Likes
1,991

Hi,

Use FM G_SET_GET_ALL_VALUES

Read only

Former Member
0 Likes
1,991

Hi,

Please try using SETHEADER and SETLEAF tables to get values of SETS. Else please on the trace when you execute the T-Code GS01 you will get the tables used for these sets.

Read only

Former Member
0 Likes
1,991

Check the below Sample code.

  • Get the internal Set-ID from the external name of the set

  • If the set class, subclass and setname is known, function module

  • G_SET_ENCRYPT_SETID must be used.

FORM GET_INTERNAL_SETID .

CALL FUNCTION 'G_SET_ENCRYPT_SETID'

EXPORTING

SETCLASS = GSETC_FISL_SETCLASS "Other classes: Type pool GSETC

SHORTNAME = G_SET

IMPORTING

SETID = P_SETID.

  • Check existence of set, send error message if set does not exist

CALL FUNCTION 'G_SET_GET_INFO'

EXPORTING

SETNAME = P_SETID.

ENDFORM.

  • Filling of the tables SETTAB and VALTAB

FORM INSERT_SET USING U_SETID LIKE SETHIER-SETID.

*..... Constants ..................................................... *

CONSTANTS: CONTROL_BLOCK LIKE SY-TABIX VALUE 1.

*..... Information about the set ..................................... *

DATA: HEADER LIKE RGSMH.

*..... Set index for differentiation of concurrently processed sets . *

DATA: SETINDEX LIKE SY-TABIX.

..... Read set into the buffer of the set manager (library GSSM) ....

  • (repeated call of G_SET_INSERT for the same set

  • will not lead to repeated database access)

CALL FUNCTION 'G_SET_INSERT'

EXPORTING

SETNAME = U_SETID

IMPORTING

HEADER = HEADER

INDEX = SETINDEX.

*..... Make entry for root set in table SETTAB ....................... *

SETTAB-SETID = HEADER-SETNR.

SETTAB-SETNAME = HEADER-SHORTNAME.

SETTAB-LEVEL = 0.

SETTAB-POINTER = 0.

APPEND SETTAB.

*----


  • Processing according set type

*----


IF HEADER-TYPE CA 'BD'.

  • ... When basic or data sets => read values ........................ *

PERFORM INSERT_VALUES

USING HEADER-SETNR HEADER-SHORTNAME HEADER-SEQNR.

ELSE.

  • ... When single or multi set => read all subsets and values ........*

CALL FUNCTION 'G_SET_GET_NEXT'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK

INDEX = SETINDEX

IMPORTING

HEADER = HEADER

EXCEPTIONS

END_OF_SETS = 1.

WHILE SY-SUBRC EQ 0. "Until all sets of hierarchy are read

  • ... Store subset of current line ................................. *

SETTAB-SETID = HEADER-SETNR.

SETTAB-SETNAME = HEADER-SHORTNAME.

SETTAB-LEVEL = HEADER-LEVEL.

SETTAB-POINTER = HEADER-PUP.

APPEND SETTAB.

  • ... Read values, if existing .....................................

IF HEADER-TYPE EQ 'B'.

PERFORM INSERT_VALUES

USING HEADER-SETNR HEADER-SHORTNAME HEADER-SEQNR.

ENDIF.

  • ... Retrieve next set ............................................

CALL FUNCTION 'G_SET_GET_NEXT'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK

INDEX = SETINDEX

IMPORTING

HEADER = HEADER

EXCEPTIONS

END_OF_SETS = 1.

ENDWHILE.

ENDIF.

*..... reset this control block so the next call of this routine *

*..... will not get the exception 'END_OF_SETS' right away *

CALL FUNCTION 'G_CONTROL_BLOCK_RESET'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK.

ENDFORM. " INSERT_SET

  • Adds value intervals to the table VALTAB *

----


FORM INSERT_VALUES USING VALUE(U_SETID) LIKE RGSMH-SETNR

VALUE(U_SETNAME) LIKE RGSMH-SHORTNAME

VALUE(U_POINTER) LIKE RGSMH-SEQNR.

*..... Constants ..................................................... *

CONSTANTS: CONTROL_BLOCK LIKE SY-TABIX VALUE 2.

*..... Information about the set line ................................ *

DATA: ENTRY LIKE RGSMV.

*..... Auxiliary fields .............................................. *

DATA: SETINDEX LIKE SY-TABIX.

*..... Transfer of the set pointer in a field with the right size .... *

SETINDEX = U_POINTER.

*..... Read all value intervals into the table VALTAB ................ *

CALL FUNCTION 'G_INTERVAL_GET_NEXT'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK

INDEX = SETINDEX

IMPORTING

ENTRY = ENTRY

EXCEPTIONS

END_OF_INTERVALS = 1.

WHILE SY-SUBRC EQ 0. "Until all values are read

  • ... Store value interval of the current set line ...................

VALTAB-SETID = U_SETID.

VALTAB-SETNAME = U_SETNAME.

VALTAB-FROMVALUE = ENTRY-FROM.

VALTAB-TOVALUE = ENTRY-TO.

VALTAB-POINTER = ENTRY-PUP.

APPEND VALTAB.

  • ... Retrieve next line .............................................

CALL FUNCTION 'G_INTERVAL_GET_NEXT'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK

INDEX = SETINDEX

IMPORTING

ENTRY = ENTRY

EXCEPTIONS

END_OF_INTERVALS = 1.

ENDWHILE.

*..... Reset this control block so the next call of this routine *

*..... will not get the exception 'END_OF_SETS' right away *

CALL FUNCTION 'G_CONTROL_BLOCK_RESET'

EXPORTING

CONTROL_BLOCK = CONTROL_BLOCK.

ENDFORM. "INSERT_VALUES

FORM GET_GL_DESCRIPTION .

IF NOT VALTAB[] IS INITIAL.

SELECT SETNAME

DESCRIPT FROM SETHEADERT INTO TABLE T_SETHEADERT

FOR ALL ENTRIES IN VALTAB WHERE SETNAME = VALTAB-SETNAME.

ENDIF.

ENDFORM. " get_gl_description

Edited by: Poorna Chandrasekhar on May 11, 2009 3:49 PM

Read only

Former Member
0 Likes
1,991