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: 

How to use the values of FM G_SET_GET_ALL_VALUES?

walkerist
Participant
0 Kudos
1,250

I want to transfer the set_values into a table and use it in a IF ENDIF logic.

Here is my code:

DATA: lt_setid LIKE sethier-setid.

CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
EXPORTING
CLIENT = sy-mandt
shortname = 'Z_CURR1'
IMPORTING
NEW_SETID = lt_setid
EXCEPTIONS
NO_SET_FOUND = 1
NO_SET_PICKED_FROM_POPUP = 2
WRONG_CLASS = 3
WRONG_SUBCLASS = 4
TABLE_FIELD_NOT_FOUND = 5
FIELDS_DONT_MATCH = 6
SET_IS_EMPTY = 7
FORMULA_IN_SET = 8
SET_IS_DYNAMIC = 9
OTHERS = 10
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
DATA: lt_set1 TYPE TABLE OF rgsb4,
lx_set1 LIKE LINE OF lt_set1,
lt_values LIKE TABLE OF lt_set1.

CALL FUNCTION 'G_SET_GET_ALL_VALUES'
EXPORTING
setnr = '0000Z_CURR1'
tables
set_values = lt_set1
EXCEPTIONS
SET_NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

Here's the data of LT_SET1 and I want to use the first entry in the code below.

IF T_EKKO_EKPO-WAERS = "FIRST ENTRY IN THE LT_SET1",

"DO SOMETHING HERE

ENDIF.

5 REPLIES 5

Sandra_Rossi
Active Contributor
0 Kudos
929

It's referred as a Table Expression in the ABAP documentation:

IF T_EKKO_EKPO-WAERS = LT_SET1[ 1 ]-WAERS.
  ...

Be careful, if LT_SET1 is empty, LT_SET1[ 1 ] will raise the exception CX_SY_ITAB_LINE_NOT_FOUND.

0 Kudos
929

I'm trying to use the LT_SET1[ 1 ]-FROM, unfortunately, it does not work correctly.

It works if the code is like this:

    IF T_EKKO_EKPO-WAERS = 'CHF'.

But it doesn't if the code is like this:

    IF T_EKKO_EKPO-WAERS = lt_set[ 1 ]-from.

0 Kudos
929

I checked in my system, no issue. What means "does not work correctly"? "doesn't work" is very subjective. Is it a syntax error? What message? If not, create a tiny program to reproduce and share it so that people can test it.

0 Kudos
929

sandra.rossi Apologies, there just has been a delay in the system upon activating the code.

Can i use CX_SY_ITAB_LINE_NOT_FOUND without using TRY CATCH?

I want to include it inside the error handling of sy-subrc <> 0.

  CALL FUNCTION 'G_SET_GET_ALL_VALUES'
EXPORTING
setnr = '0000ZCURR1'
TABLES
set_values = lt_curr
EXCEPTIONS
SET_NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

0 Kudos
929

Exception classes can be handled only with TRY CATCH. Exceptions are not related to SY-SUBRC.

Possibly make sure that there's at least one line to avoid the exception.

IF LT_SET1 IS NOT INITIAL AND T_EKKO_EKPO-WAERS = LT_SET1[ 1 ]-WAERS.

Also it's possible to use this predicate function (won't trigger an exception):

IF line_exists( LT_SET1[ 1 ] ).