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: 

why system variants.

Former Member
0 Kudos

hey,

i have two questions to confirm.

1-why we go for system variants, avoiding normal variants. could you tell me the situations where we only use system variants(&CUS).

2-why fieldsymbols introduced in ABAP.

In which case we advised to use Fieldsymbol.

could you tell me example.is it replacement of ord variable?

(I know FS dont take memory till runtime...otherwise any advantages?)

could you pls clearcut point rather refering R/3libary or manuals.

could be more appreciatable.(examples more welcome)

ambichan.

Message was edited by: ambi chan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ambichan,

1. System variants are used so that multiple users can use the same variant. this could be the case where multiple QA users are testing a report program, or in case of the ned users, where some applications need to run with the same data irrespective of who is running the program.

2. Field-symbols are primarily used for dynamic programming in ABAP. There was an excellent <a href="/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table">weblog</a> by Subramanian some time back. You can refer to that for their use.

Regards,

Anand Mandalika.

4 REPLIES 4

Former Member
0 Kudos

Hi Ambichan,

1. System variants are used so that multiple users can use the same variant. this could be the case where multiple QA users are testing a report program, or in case of the ned users, where some applications need to run with the same data irrespective of who is running the program.

2. Field-symbols are primarily used for dynamic programming in ABAP. There was an excellent <a href="/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table">weblog</a> by Subramanian some time back. You can refer to that for their use.

Regards,

Anand Mandalika.

0 Kudos

And regarding field-symbols, I will give you an example where you have to use field-symbols. You cannot get the solution without using them.

This example is directly taken from Subramanian's weblog, with a minor extension.

REPORT  ztest_fieldsymbols.

PARAMETERS: p_table TYPE dd02l-tabname.

DATA: lv_dref   TYPE REF TO data,
      it_fnames LIKE dd03l-rollname OCCURS 0 WITH HEADER LINE.

FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE,
               <fs_line>,
               <fs_field>.


START-OF-SELECTION.

  CREATE DATA lv_dref TYPE TABLE OF (p_table).

  ASSIGN lv_dref->* TO <fs_table>.

  SELECT *
    FROM (p_table)
    INTO TABLE <fs_table>.

  LOOP AT <fs_table> ASSIGNING <fs_line>.
    DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <fs_line> TO <fs_field>.
      IF sy-subrc NE 0.
        EXIT.
      ELSE.
        IF sy-index EQ 1.
          WRITE: / <fs_field>.
        ELSE.
          WRITE: <fs_field>.
        ENDIF.
      ENDIF.
    ENDDO.
  ENDLOOP

.

In the above example, the user can enter the name of any database table in the selection-screen, and the contents of that table are displayed on the list.

You can try out with SPFLI , T000, SFLIGHT etc.,

Regards,

Anand Mandalika.

P.S. The program above is just an example, aand the list output will not be too clear in case of tables with a large number of fields.

Former Member
0 Kudos

Hi,

Field-Symbols are similar to pointers in C.

I will give u a sample coding for building field catalog in ALV using Field symbols.

FIELD-SYMBOLS : <lfs_fieldcat> TYPE lvc_s_fcat.

LOOP AT p_fieldcat ASSIGNING <lfs_fieldcat>.

CASE <lfs_fieldcat>-fieldname.

WHEN 'GL_ACCT'.

<lfs_fieldcat>-coltext = text-050.

<lfs_fieldcat>-no_out = ' '.

.

.

ENDCASE.

ENDLOOP.

Similarly u can try using field-symbols.

Also u can serach the forum to get some more samples.

Thanks & Regards,

Judith.

Former Member
0 Kudos

Hi,

Can also refer to this link for field symbols

http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap for power users

Thanks & Regards,

Judith.