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

how to select a structure

Former Member
0 Likes
1,097

Hi everyone,

I've been assigned to do a user exit. One of the specs require me to select field IWERK from structure CAUFVD.

My questions are:

1. How do i declare a structure like this in the user exit

2. How do i do a SELECT from a structure?

Hi everyone,

I've been assigned to do a user exit. One of the specs require me to select field IWERK from structure CAUFVD.

My questions are:

1. How do i declare a structure like this in the user exit

2. How do i do a SELECT from a structure?

6 REPLIES 6
Read only

Former Member
0 Likes
1,032

Hi Bernard..

You cannot select from a structure cause it does not hold any data. It is just for temperory storage.

Check this post..

Thanks,

Susmitha.

Reward points for useful answers.

Read only

Former Member
0 Likes
1,032

Bernard,

You cannot select from a structure, can do only from a table. In this case you might have to look at AUFK, AUFC tables.

Declaration can be something like this

DATA : WA_CAUFVD LIKE CAUFVD.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

Former Member
0 Likes
1,032

HI

GOOD

YOU HAVE TO DECLARE LIKE THIS

TYPES: BEGIN OF struct,

number_1 TYPE i,

number_2 TYPE p DECIMALS 2,

END OF struct.

SELECT FROM A STRUCTURE=>

USING THE SELECT STATEMENT YOU CAN SELECT FROM THE STRUCTURE.

https://help.sap.com/saphelp_nw04s/helpdata/en/90/8d7301b1af11d194f600a0c929b3c3/frameset.htm

THANKS

MRUTYUN

Read only

Former Member
0 Likes
1,032

Hi bernard,

1. As u said u are working on user exit,

2. This structure CAUFVD

will be passed by the user-exit FM.

(It will be an Import parameter in this FM)

3. There is no need to do any select.

4. Just check out your FM

the structure CAUFVD

will be having some name in import parameter,

eg. I_CAUFVD

5. Just do I_CAUFVD-IWERK.

regards,

amit m.

Read only

Former Member
0 Likes
1,032

Hai

try this example:

=====================================

REPORT zmaschl_create_data_dynamic .

TYPE-POOLS: slis.

DATA: it_fcat TYPE slis_t_fieldcat_alv,

is_fcat LIKE LINE OF it_fcat.

DATA: it_fieldcat TYPE lvc_t_fcat,

is_fieldcat LIKE LINE OF it_fieldcat.

DATA: new_table TYPE REF TO data.

DATA: new_line TYPE REF TO data.

FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,

<l_line> TYPE ANY,

<l_field> TYPE ANY.

  • Build fieldcat

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SYST'

CHANGING

ct_fieldcat = it_fcat[].

LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.

MOVE-CORRESPONDING is_fcat TO is_fieldcat.

is_fieldcat-fieldname = is_fcat-fieldname.

is_fieldcat-ref_field = is_fcat-fieldname.

is_fieldcat-ref_table = is_fcat-ref_tabname.

APPEND is_fieldcat TO it_fieldcat.

ENDLOOP.

  • Create a new Table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = new_table.

  • Create a new Line with the same structure of the table.

ASSIGN new_table->* TO <l_table>.

CREATE DATA new_line LIKE LINE OF <l_table>.

ASSIGN new_line->* TO <l_line>.

  • Test it...

DO 30 TIMES.

ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.

<l_field> = sy-index.

INSERT <l_line> INTO TABLE <l_table>.

ENDDO.

LOOP AT <l_table> ASSIGNING <l_line>.

ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.

WRITE <l_field>.

ENDLOOP.

Thanks & regards

Sreeni

Read only

Former Member
0 Likes
1,032

Hi,

1. STRUCTURE WILL NEVER STORE DATA.

2. TABLE STORES DATA. BUT STRUCTURE NEVER STORES DATA.

If this structure is an import parameter of ur exit-FM

then u can directly get this value like this:

variable = CAUFVD-IWERK.

rgds,

latheesh