Append a new line while using Field Symbols

Hi,
Below is a snippet of my code
DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].
FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].
zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).
<ls_data_package>-/bic/zd_user = <ls_data_package>-/bic/zbib_sysn(off).
<ls_data_package>-/bic/zwrk = <ls_data_package>-/bic/zbib_sysn+off1.
I want to insert a new line to the data package, with all the fields same while adding the above two,
except for,
<ls_data_package>-/bic/zd_user = zbib_sysn_temp
<ls_data_package>-/bic/zitm = 2.
Note: by default the field /bic/zitm = 1. So while adding for the 1st time it is set to 1 by default. I want to add a second (new line) to the datapackage which has all fields same except for the /bic/zd_user and the /bic/zitm = 2.
Please help me with this code,
CD

Souvrav, thanks for the reply.
I am not an ABAP'er, I have managed to write code so far. Can you please help me with how this can be done in this code:
  DATA: off, off1, off2, off3, off4, off5, off6 TYPE i.
  DATA: zbib_sysn_temp TYPE string.
  DATA: ls_data_package LIKE LINE OF DATA_PACKAGE[].
  FIELD-SYMBOLS:<ls_data_package> LIKE LINE OF DATA_PACKAGE[].
  SORT DATA_PACKAGE BY /bic/zbib_id.
  LOOP AT DATA_PACKAGE ASSIGNING <ls_data_package>.
    IF <ls_data_package>-/bic/zbib_sysn IS NOT INITIAL.
      TRANSLATE <ls_data_package>-/bic/zbib_sysn TO UPPER CASE.
      FIND '/' IN <ls_data_package>-/bic/zbib_sysn MATCH OFFSET off2.
        zbib_sysn_temp = <ls_data_package>-/bic/zbib_sysn+off3(off4).
IF sy-subrc EQ 0.
            <ls_data_package>-/bic/zd_user =
            <ls_data_package>-/bic/zbib_sysn(off).
Now at this point of code i want to copy this existing record from ls_data_package to create a new record where /bic/zd_user = zbib_sysn_temp and /bic/zitm = 2.
Pleas help...

Similar Messages

  • Going for dump while using field symbols

    Hi all,
       I am using field symbols in my program. Program is going dump for some company codes and working fine for some company codes.
    I am confused. Please check this code where the error is shown.
    LOOP AT i_final ASSIGNING <fs_final>.
        AT NEW belnr.
         if  <fs_final>-wt_withcd  = 'SF' or  <fs_final>-wt_withcd  = 'XF' OR  <fs_final>-  wt_withcd  = 'WF'.
          MOVE <fs_final> TO wa_final1.
          g_qsatz = wa_final1-qsatz.
          APPEND wa_final1 TO i_final1.
          CLEAR wa_final1.
         ENDIF.
        ENDAT.
        READ TABLE i_final1 ASSIGNING <fs_final1> WITH KEY belnr = <fs_final>-belnr.
        IF <fs_final>-wt_withcd  = 'SF'.
          <fs_final1>-wt_withcd1 = <fs_final>-wt_withcd.
          <fs_final1>-wt_qbshb1  = <fs_final>-wt_qbshb.
          <fs_final1>-qsatz      = <fs_final1>-qsatz + <fs_final>-qsatz.
        ENDIF.
        IF <fs_final>-wt_withcd  = 'XF'.
          <fs_final1>-wt_withcd2 = <fs_final>-wt_withcd.
          <fs_final1>-wt_qbshb2  = <fs_final>-wt_qbshb.
          <fs_final1>-qsatz      = <fs_final1>-qsatz + <fs_final>-qsatz.
        ENDIF.
        IF <fs_final>-wt_withcd = 'WF'.
          <fs_final1>-wt_withcd = <fs_final>-wt_withcd.
          <fs_final1>-wt_qbshb  = <fs_final>-wt_qbshb.
          <fs_final1>-qsatz      = <fs_final1>-qsatz + <fs_final>-qsatz.
        ENDIF.
        AT END OF belnr.
          <fs_final1>-qsatz = <fs_final1>-qsatz - g_qsatz.
          clear g_qsatz.
        ENDAT.
      ENDLOOP.
    Please check the code and help me.
    Thanks in advance,
    Shalem

    HI Shalem
    Please check this code:
    LOOP AT i_final ASSIGNING <fs_final>.
      AT NEW belnr.
         if <fs_final>-wt_withcd = 'SF' or
            <fs_final>-wt_withcd = 'XF' OR
            <fs_final>- wt_withcd = 'WF'.
            MOVE <fs_final> TO wa_final1.
            g_qsatz = wa_final1-qsatz.
            APPEND wa_final1 TO i_final1.
            CLEAR wa_final1.
         ENDIF.
      ENDAT.
      READ TABLE i_final1 ASSIGNING <fs_final1> WITH KEY belnr = <fs_final>-belnr.
      IF sy-subrc EQ 0.
         CASE <fs_final>-wt_withcd.
         WHEN 'SF'.
              <fs_final1>-wt_withcd1 = <fs_final>-wt_withcd.
              <fs_final1>-wt_qbshb1 = <fs_final>-wt_qbshb.
         WHEN 'XF'.
              <fs_final1>-wt_withcd2 = <fs_final>-wt_withcd.
              <fs_final1>-wt_qbshb2 = <fs_final>-wt_qbshb.
         WHEN 'WF'.
              <fs_final1>-wt_withcd = <fs_final>-wt_withcd.
              <fs_final1>-wt_qbshb = <fs_final>-wt_qbshb.
         ENDCASE.
         <fs_final1>-qsatz = <fs_final1>-qsatz + <fs_final>-qsatz.
         AT END OF belnr.
            <fs_final1>-qsatz = <fs_final1>-qsatz - g_qsatz.
            clear g_qsatz.
         ENDAT.
      ENDIF.
    ENDLOOP.
    Kind Regards
    Eswar

  • Using Field-Symbols in a user exit to change the importing parameter

    Please don't ask why but I need to use a user exit, changing the importing parameter.  I decided that I could do this using field-symbols.
    Please excuse my ignorance but I have never used field symbols for something such as this.
    Here is my goal:  Loop through an internal table (im_document-item).  When I find what I need I want to make a change to this line (not so hard if I am looping into a field symbol) and also append a line to the end of the table im_document-item.
    I have the following so far:
      DATA: wa_item TYPE accit,
            wa_item_out type ACCIT_SUB.
    FIELD-SYMBOLS: <document> type acc_document,
                   <accit> TYPE ACCIT.
    LOOP AT im_document-item ASSIGNING <accit> where saknr = '0000211000'.
    * Modify the curent line
    wa_item = <accit>
    * Append a new line into table im_document-item.
    ENDLOOP.
    How can I use field-symbols to append a line to this table?  Please note that the table in question (im_document-item) is an importing only parameter.
    Regards,
    Davis

    that will allow me to append an initial line with <accit> pointing to the line. Therefore I just have to modify <accit> and the new line will then have my changes?
    Yep, that is exactly it.    So after the APPEND statement, simply fill the fields of the <accit>.
    append initial line to im_document-item ASSIGNING <accit>.
    <accit>-field1 = 'Blah'.
    <accit>-field2 = 'Blah'.
    Regards,
    Rich Heilman

  • How to use field symbol in select

    Hi,
        CONCATENATE 'WTG0' LV_MON INTO LV_FNAME.
        ASSIGN (LV_FNAME) TO <FS>.
        SELECT SINGLE <FS>  FROM COSP INTO LV_SAPRST
             WHERE OBJNR = LV_OBJ AND GJAHR = LV_YEAR AND WRTTP = '4' AND KSTAR = GT_INOUT-SAKNR
       Error message :    Unknown column name "<FS>" . field list. . field list. field list. 
       actually ,  if i use  if command,  i can do,  but i want to use simple code by fieldsymbol.
       is it possible in select command?
    Thanks in advance
    Benjamin

    Hi
    Hope it will help you.
    reward if help.
    Field Symbols
    Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
    Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
    Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    Related
    ASSIGN, DATA
    Additional help
    Declaring Field Symbols

  • How to use field symbols in program

    how to use field symbols can any one explain with example please..
    Regards,
    venki...

    Hi
    Field Symbols
    Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
    Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
    Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Re: Problem in ALV reports using Field symbols

    Hi Friends,
    Can you tell me how to convert a normal report using field symbols into ALV report
    can ypu please suggest me any solutions.I am sending the code along with this mail.
    Regards,
    Dinesh
    <b>Coding:</b>
    *& Report  YSDBTEMP                                                    *
    REPORT  YSDBTEMP                                .
    tables: ekko , ekpo .
    TYPE-POOLS: SLIS.
    *Internal Table Declaration
    data: begin of line ,
          ebeln like ekko-ebeln , "Purchasing Document No.
          bedat like ekko-bedat , "Purchasing Document Date
          matnr like ekpo-matnr , "Material No.
          netwr like ekpo-netwr , "Net Order Value in PO Currancy
          meins like ekpo-meins , "UOM
          change like ekpo-menge ,
    end of line .
    *Internal table Declaration
    DATA: IT_final like table of line  with header line.
    DATA :  FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV with header line.
    DATA :  V_REPID TYPE SYREPID.
    DATA :  IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    data :  i_layout type slis_layout_alv .
    Header for Main Grid Display
    data:i_header1 type slis_t_listheader with header line.
    Header for Interactive Report Display
    data:i_header2 type slis_t_listheader with header line.
    *Field Symbol declaration.
    FIELD-SYMBOLS: <FS> type any table.
    **select option Declaration
    selection-screen begin of block block.
    select-options: s_ebeln for ekko-ebeln .
    selection-screen end of block block .
    start-of-selection.
      perform get_data.
      perform field_cat.
      perform layout using i_layout .
      perform grid_display .
    *&      Form  get_data
          text
    -->  p1        text
    <--  p2        text
    FORM get_data .
    SELECT EKKO~EBELN
      EKKO~BEDAT
      EKPO~EBELP
      EKPO~MATNR
      EKPO~NETWR
      EKPO~MEINS
      EKPO~MENGE
      EKPO~BPRME
      INTO CORRESPONDING FIELDS OF table IT_FINAL
      FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
      WHERE EKKO~EBELN IN S_EBELN.
    ENDFORM.                    " get_data
    *&      Form  field_cat
          text
    -->  p1        text
    <--  p2        text
    FORM field_cat .
      fieldcatalog-fieldname = 'EBELN'.
      fieldcatalog-seltext_m = 'Purchase Order No'.
      fieldcatalog-col_pos = 1.
       append fieldcatalog .
      clear fieldcatalog.
      fieldcatalog-fieldname = 'BEDAT'.
      fieldcatalog-seltext_m = 'Purchasing Document Date'.
      fieldcatalog-col_pos = 2.
       append fieldcatalog .
      clear fieldcatalog.
      fieldcatalog-fieldname = 'MATNR'.
      fieldcatalog-seltext_m = 'Material No'.
      fieldcatalog-col_pos = 3.
       append fieldcatalog .
      clear fieldcatalog.
      fieldcatalog-fieldname = 'MATNR'.
      fieldcatalog-seltext_m = 'Net order'.
      fieldcatalog-col_pos = 4.
       append fieldcatalog .
      clear fieldcatalog.
    ENDFORM.                    " field_cat
    *&      Form  layout
          text
         -->P_I_LAYOUT  text
    FORM layout  USING    P_I_LAYOUT.
      i_layout-lights_tabname = 'IT_FINAL'.
      i_layout-box_tabname = 'IT_FINAL'.
    ENDFORM.                    " layout
    *&      Form  grid_display
          text
    -->  p1        text
    <--  p2        text
    FORM grid_display .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'
      I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
      IS_LAYOUT = I_LAYOUT
      IT_FIELDCAT = FIELDCATALOG[]
    *IT_EVENTS = I_EVENT[]
      TABLES
      t_outtab = <fs>.
    endform.

    Hi,
    This is one sample program,
    Check this.
    I hope it is helpful to you.
    TABLES : zeastable_02,zeastable_04.
    TYPE-POOLS : slis.
    TYPES : BEGIN OF fieldst,
            name LIKE zeastable_02-name,
            znum LIKE zeastable_02-znum,
            empno LIKE zeastable_04-empno,
            zempsalary LIKE zeastable_04-zempsalary,
            END OF fieldst.
    DATA itab TYPE TABLE OF fieldst WITH HEADER LINE.
    DATA: w_report_id  LIKE sy-repid.            "Program name
    DATA: w_title   TYPE lvc_title VALUE    'Assignment 1 in ALV'.
    DATA: w_layout   TYPE slis_layout_alv.      "Layout setup
    DATA: w_fieldcat TYPE slis_t_fieldcat_alv.  "Field Catlog
    START-OF-SELECTION.
      SELECT-OPTIONS employee FOR zeastable_04-empno.
    SELECT zeastable_02name  zeastable_02znum
           zeastable_04empno zeastable_04zempsalary
           INTO CORRESPONDING FIELDS OF TABLE itab FROM
           zeastable_02 INNER JOIN zeastable_04 ON
           zeastable_02name = zeastable_04name
           WHERE  zeastable_04~empno IN employee.
    w_report_id = sy-repid.
    PERFORM i_layout CHANGING w_layout.
    PERFORM i_fieldcat CHANGING w_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
        i_callback_program                = 'ZEASALV_04'
         i_grid_title                      = w_title
         is_layout                         = w_layout
         it_fieldcat                       = w_fieldcat
         i_save                            = 'A'
        TABLES
          t_outtab                          = itab
       EXCEPTIONS
         program_error                     = 1
         OTHERS                            = 2
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      PERFORM i_layout CHANGING w_layout.
      PERFORM i_fieldcat CHANGING w_fieldcat.
    *&      Form  i_layout
          text
         <--P_W_LAYOUT  text
    form i_layout  changing p_w_layout.
    clear w_layout.
      w_layout-colwidth_optimize = 'X'.
      w_layout-edit = ' '.
    endform.                    " i_layout
    *&      Form  i_fieldcat
          text
         <--P_W_FEILDCAT  text
    form i_fieldcat  changing p_w_feildcat.
    data: l_line_fieldcat type slis_fieldcat_alv.
    clear l_line_fieldcat.
      l_line_fieldcat-fieldname = 'NAME'.
      l_line_fieldcat-ref_tabname = 'itab'.
      l_line_fieldcat-seltext_m = 'NAME'.
      l_line_fieldcat-key  = 'X'.
       append l_line_fieldcat to w_fieldcat.
      clear l_line_fieldcat.
      l_line_fieldcat-fieldname = 'ZNUM'.
      l_line_fieldcat-ref_tabname = 'itab'.
      l_line_fieldcat-seltext_m = 'NUMBER'.
      l_line_fieldcat-key  = 'X'.
      append l_line_fieldcat to w_fieldcat.
      clear l_line_fieldcat.
      l_line_fieldcat-fieldname = 'EMPNO'.
      l_line_fieldcat-ref_tabname = 'itab'.
      l_line_fieldcat-seltext_m = 'EMPLNUM'.
    *l_line_fieldcat-key  = 'X'.
      append l_line_fieldcat to w_fieldcat.
      clear l_line_fieldcat.
      l_line_fieldcat-fieldname = 'ZEMPSALARY'.
      l_line_fieldcat-ref_tabname = 'itab'.
      l_line_fieldcat-seltext_m = 'SALARY'.
    *l_line_fieldcat-key  = 'X'.
      append l_line_fieldcat to w_fieldcat.
    endform.                    " i_fieldcat
    Reward for useful answers.

  • Header Line Logic for Field Symbols??

    Hi Experts,
    I have the logic
    DATA: Itab  TYPE REF TO DATA.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE.
    CREATE DATA Itab TYPE STANDARD TABLE OF (TABLE_NAME).
    ASSIGN Itab->* TO <itab>.
    Her I had done the dynamic logic
    select (LT_FIELDS)
           into corresponding fields of table <itab>
           from (TABLE_NAME)
          up to 100 rows
           WHERE (LT_WHERE).
    Now I am having all information in <itab>.
    Now I want to take this headerline information of <itab> and populate the same to other structure??
    How to take the <itab> as header line information by looping??

    Hi
    see this and use
    Field Symbols
    Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
    Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to each field symbol before you can address the latter in programs.
    Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    Regards
    ANJI

  • Dynamic internal  tables using field symbols

    Hello,
    Is it possible to create a dynamic table where the no of fields in the internal table can be created dynamically(using field symbols).
    Say sometimes internal tables with 10 fields and depending upon the requirement the fields can be dynamically increased or decreased in runtime.
    Thanks.

    Hi,
    Go through the following code....
    *Data definitions
    *** Tables
    data: lt_data type ref to data.
    data: lt_fieldcatalog type lvc_t_fcat.
    *** Structure
    data: ls_fieldcatalog type lvc_s_fcat.
    *** Data References
    data: new_line type ref to data,
          fs_data type ref to data.
    *** Field Symbols
    field-symbols: <fs_data> type ref to data,
                   <fs_1> type any table,
                   <fs_2>,
                   <fs_3>.
    *Populating the internal table with fieldnames required for our dynamic
    *internal table
    ls_fieldcatalog-fieldname = 'MANDT'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
    ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CONNID'.
    ls_fieldcatalog-inttype = 'N'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'FLDATE'.
    ls_fieldcatalog-inttype = 'D'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'PRICE'.
    ls_fieldcatalog-inttype = 'P'.
    append ls_fieldcatalog to lt_fieldcatalog.
    ls_fieldcatalog-fieldname = 'CURRENCY'.
    ls_fieldcatalog-inttype = 'C'.
    append ls_fieldcatalog to lt_fieldcatalog.
    *Calling the method CREATE_DYNAMIC_TABLE
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = lt_fieldcatalog
         importing
           ep_table = fs_data
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    if sy-subrc <> 0.
    endif.
    *Assigning Field-Symbol to our dynamic internal table
    assign lt_data to <fs_data>.
    *Internal Table is ready, now to put data in that table
    *** So <FS_1> now points to our dynamic internal table.
    assign fs_data->* to <fs_1>.
    *** Next step is to create a work area for our dynamic internal table.
    create data new_line like line of <fs_1>.
    *** A field-symbol to access that work area
    assign new_line->*  to <fs_2>.
    *** And to put the data in the internal table
    select
          mandt
          carrid
          connid
          fldate
          price
          currency
                  from sflight
                  into corresponding fields of table <fs_1>.
    *** Access contents of internal table
    loop at <fs_1> assigning <fs_2>.
    do 5 times.
    assign component sy-index of structure <fs_2> to <fs_3>.
    write:  <fs_3>.
    enddo.
    skip 1.
    endloop.
    top-of-page.
    write:/5 'FUJITSU CONSULTING COMPANY' inverse color 6,
           50 sy-datum inverse color 6,
           70 sy-pagno inverse color 6.
    uline.
    <REMOVED BY MODERATOR>
    Vijay C
    Code Formatted by: Alvaro Tejada Galindo on Apr 14, 2008 1:47 PM

  • Modify DB by single field using Field Symbol

    Hi,
      please help me ,actually i have not use the field symbol in any object. i have one requirement ,i have to modify the DB by field STATUS using Field symbol ,
    I am sending u my code so please help me how can i modify DB using field symbol..
              gw_msg3_status1   = k_status1 .
              LOOP AT gi_msg3 INTO gs_msg3.
                gs_msg3-status  = gw_msg3_status1 .
                gs_msg3-issue   = lw_issuno.
           MODIFY gi_msg3 FROM gs_msg3 TRANSPORTING status.
                MODIFY gi_msg3 INDEX sy-tabix FROM gs_msg3 TRANSPORTING issue status.
              ENDLOOP.
    Thanks & Regards,
    Meenakshi

    perform dboperation_table using 'SET' 'BIRTHDT' '=' <fs>.
        perform dboperation_table using 'WHERE' 'PARTNER' '='  <fs>
        perform dboperation_update using 'BUT000'.
    form dboperation_table
    using p_type
          p_var1
          p_var2
          p_var3.
      data: t_l type cmst_str_data.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          clear t_l.
          if p_var3 is not initial.
            t_l = p_var3.
            condense t_l.
            concatenate '''' t_l '''' into t_l.
          endif.
          concatenate p_var1 p_var2 t_l into t_l
          separated by space.
          case p_type.
            when 'SET'.   append t_l to g_s_t.
            when 'WHERE'. append t_l to g_w_t.
          endcase.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_table
    form dboperation_update
    using  p_tabname type zdboperation-tabname.
      data: tabname type bus_table.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          tabname-tabname = p_tabname.
          call function 'ZDBOPERATION_UPDATE'
            in update task
            exporting
              tabname     = tabname
            tables
              where_table = g_w_t
              set_table   = g_s_t.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_update
    Hope it will help you.
    Regards,
    Madan.

  • How to trigger New page while using ALV with classes/oops?

    Hi All
    I am trying to print a report which has to show the data in two pages.
    I am using ALV with classes/oops.
    Though I am able to print the report but a new page is not coming. Whole of the data is coming in one single page.
    Please tell me as to how to trigger a NEW PAGE while using ALV with classes/oops.
    Please send some code samples also if available.
    Thanks in advance.
    Jerry

    using sort option you can do it. in case of grid/oo alv class ALV you can view that only in print mode/preview mode.
    in case of list you can view that directly.
    sort-fieldname = 'FIELDNAME'.
    sort-group = '*'  "triggers new page
    sort-up = 'X'.
    append sort to it_sort.

  • How to populate one internal table from another using field symbols

    Hi Gurus,
      I have a problem. I have to populate one internal table (sructure t_otput) from another internal table (sructure t_from) using field symbol.
    Structure for from table.
    types: begin of t_from,
             year(4) type c,
             ww(2) type c,
             site type marc-werks,
             demand type i,
           end of t_from.
    Structure for output table.
    types: begin of t_display,
             title(30),
             WW1(10),
             WW2(10),
             WW3(10),
           end of t_display.
    The from table looks like this:
    Year | WW | Site | Demand
    2005 | 1  | OR1  | 12.00
    2005 | 2  | OR1  | 13.00
    2005 | 3  | OR1  | 14.00
    The display table which has to be populated should look like this:
    Title  | WW1   | WW2   | WW3
    OR1    |       |       |
    Demand | 12.00 | 13.00 | 14.00
    How to populate display table using field symbol?
    Please give code snippets
    Thanks,
    Gopal

    Gopal,
    Here is the code, however I am not vary clear about the ORG1 and Demand display that you have shown in the display. I am sure with this code it should not be a big deal to tweak in whatever manner you want.
    TABLES : marc.
    TYPES: BEGIN OF type_display,
    title(30),
    ww1(10),
    ww2(10),
    ww3(10),
    END OF type_display.
    TYPES: BEGIN OF type_from,
    year(4) TYPE c,
    ww(2) TYPE c,
    site TYPE marc-werks,
    demand TYPE i,
    END OF type_from.
    data : t_from type table of type_from,
           t_display type table of type_display.
    field-symbols : <fs_from> type type_from,
                    <fs_display> type type_display.
    data : wa_from type type_From,
           wa_display type type_display.
    wa_from-year = '2005'.
    wa_from-ww   = '1'.
    wa_from-site = 'OR1'.
    wa_from-demand = '12.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '2'.
    wa_from-site = 'OR1'.
    wa_from-demand = '13.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '3'.
    wa_from-site = 'OR1'.
    wa_from-demand = '14.00'.
    insert wa_from  into table t_from.
    data : variable(3) type c.
    field-symbols : <fs_any> type any.
    break-point.
    Loop at t_from assigning <fs_from>.
    variable = 'WW'.
    wa_display-title = <fs_from>-site.
    concatenate variable <fs_from>-ww into variable.
    assign component variable of structure wa_display to <fs_any>.
    <fs_any> = <fs_from>-demand.
    endloop.
    append wa_display to t_display.
    clear wa_display.
    loop at t_display assigning <Fs_display>.
      write :/ <fs_display>.
    endloop.
    Note : Please award points if this helps you.
    Regards,
    Ravi

  • Delete row from internal table using field symbol.

    Hi friends,
      I created dynamic internal table using field symbol. I want to delete some data using where clause.
    for example. i want to use like,
        DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
    Like the above statment it won't work. How i can use delete with where clause in field symbols.
    Hope any one can help me.
    Thanks and regards
    Srikanth. S

    hi Srikanth,
    I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
    LOOP at <itab> INTO <wa>.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
    CHECK <field> IS ASSIGNED.
    IF <field> EQ WA_KNA1-KUNNR.
    DELETE ...
    ENDIF.
    UNASSIGN <field>.
    ENDLOOP.
    hope this helps
    ec

  • Data Maintain in a table form another table....using field symbols.

    Hi,
    I am using dynamic table concepts.I am using field symbols.I need to maintain two tables of similar structure.
    when i append data it will enter into both tables.when i unassign first table and reassign it ,i am getting back that data again into first table ..how to slve this problem.i need to start first table as fresh table and second table contain copy of the first table.

    Hi,
    maybe you should clarify your problem a bit more by pasting some code and try to explain it a bit more in detail.
    Roy

  • How to add new line item using BAPI BAPI_CONTRACT_CHANGE for contract-ME32K

    HI Experts,
    how to add new line item using BAPI: BAPI_CONTRACT_CHANGE for existing contract.
    Requirement:
    Already the contract having two line items using ME31K.
    Custom program has to add new line items in existing contract.
    Thanks,
    Sendil

    I got the solution:
    We can do like this:
    1. Get all details using details, BAPI_CONTRACT_GETDETAIL.
    2. After getting results, append new line item. Then use your BAPI.
    Check this posting program.. where this bapi is used, use the same coding technique.
    IDOC_INPUT_PURCONTRACT_CHANGE

  • Perform setting OOP ALV for multiple reports using Field Symbols

    Hi, Abapers ... i try to write a programme which using ONE oop ALV but 2 different structure internal table. the last result should be 2 radio button. first button is r_wbs and 2ns r_kpi. r_wbs will display 4 column answer and r_kpi will display 10 columns answer with different column name. i successfully implemented using FIELDS SYMBOLS but the problems i failed to perform customized setting forALV (report's tittle, column name, different layout etc)  for 2 different reports.  this is the programme. Please Give Opinion, simple example will be more helpful. Thanks You Very Much
    *&this report experimental how to print into ONE alv
    *&with 2 diffrent structure internal table
    REPORT  zfiroopalv.
    SELECTION-SCREEN BEGIN OF BLOCK mode WITH FRAME TITLE text-002.
    PARAMETERS r_wbs RADIOBUTTON GROUP mode DEFAULT 'X'.
    PARAMETERS r_kpi RADIOBUTTON GROUP mode.
    SELECTION-SCREEN END OF BLOCK mode.
    CLASS lcl_main DEFINITION.
    PUBLIC SECTION.
    CLASS-DATA: md_wbs TYPE c LENGTH 1.
    METHODS: process,
             write.
    DATA: mdo_data TYPE REF TO data.
    TYPES: BEGIN OF st_wbs,
    rsnum TYPE zmeime002a-rsnum,
    rspos TYPE zmeime002a-rspos,
    a TYPE zmmgitab01-menge,
    b TYPE zmeime002a-bdmng,
    c TYPE zmeime002a-bdmng,
    d TYPE zmeime002a-bdmng,
    e TYPE zmeime002a-bdmng,
    f TYPE zmmgitab01-menge,
    g TYPE zmmgitab01-menge,
    END OF st_wbs.
    TYPES: BEGIN OF st_kpi,
    regio TYPE zmeime002a-regio,
    gsber TYPE zmeime002a-gsber,
    gtext TYPE zmeime002a-gtext,
    x TYPE zmmgitab01-menge,
    y TYPE zmmgitab01-menge,
    z TYPE zmmgitab01-menge,
    END OF st_kpi.
    CLASS-DATA: it_wbs TYPE TABLE OF st_wbs,
                wa_wbs LIKE LINE OF it_wbs.
    CLASS-DATA: it_kpi TYPE TABLE OF st_kpi,
                wa_kpi LIKE LINE OF it_kpi.
    PRIVATE SECTION.
    DATA: set_display_setting TYPE REF TO cl_salv_table.
    DATA: display_settings TYPE REF TO cl_salv_display_settings.
    DATA: salv_table TYPE REF TO cl_salv_table.
    DATA: error TYPE REF TO cx_root.
    DATA: errtext TYPE string.
    ENDCLASS.
    CLASS lcl_kpi DEFINITION INHERITING FROM lcl_main.
    PUBLIC SECTION.
    METHODS: process_kpi.
    PRIVATE SECTION.
    ENDCLASS.
    * C.L.A.S.S lcl_main D.E.F.I.N.I.T.I.O.N
    CLASS lcl_wbs DEFINITION INHERITING FROM lcl_main.
    PUBLIC SECTION.
    METHODS: process_wbs.
    PRIVATE SECTION.
    ENDCLASS.
    * m.a.i.n. .p.r.o.g.r.a.m.
    START-OF-SELECTION.
      DATA: o_main TYPE REF TO lcl_main.
    DATA: p_wbs TYPE c.
    CREATE OBJECT o_main.
      CASE 'X'.
      WHEN r_wbs.
          o_main->md_wbs = 'X'.
      WHEN r_kpi.
          o_main->md_wbs = ' '.
      ENDCASE.
      o_main->process( ).
      o_main->write( ).
    CLASS lcl_main IMPLEMENTATION.
    *ENDMETHOD.
    METHOD process.  " NOTE: public method
    DATA: o_main TYPE REF TO lcl_main,
          o_wbs TYPE REF TO lcl_wbs,
          o_kpi TYPE REF TO lcl_kpi.
    CREATE OBJECT: o_wbs,o_kpi.
      IF ( me->md_wbs = 'X' ).
          CALL METHOD o_wbs->process_wbs( ).  " NOTE: private method
          GET REFERENCE OF me->it_wbs INTO me->mdo_data.
      ELSE.
          CALL METHOD o_kpi->process_kpi( ).  " NOTE: private method
          GET REFERENCE OF me->it_kpi INTO me->mdo_data.
      ENDIF.
    ENDMETHOD.
    METHOD write.
    FIELD-SYMBOLS:
      <lt_outtab>    TYPE table.
      ASSIGN me->mdo_data->* TO <lt_outtab>.
    cl_salv_table=>factory(
    EXPORTING
    list_display = if_salv_c_bool_sap=>false
    IMPORTING
    r_salv_table = salv_table
    CHANGING
    t_table = <lt_outtab>
    salv_table->display( ).
    ENDMETHOD.
    ENDCLASS.
    CLASS lcl_kpi IMPLEMENTATION.
    METHOD process_kpi.
    *********** run some select statement into it_kpi*******
    ENDMETHOD.
    ENDCLASS.
    CLASS lcl_wbs IMPLEMENTATION.
    METHOD process_wbs.
    *********** run some select statement into it_wbs*******
    ENDMETHOD.
    ENDCLASS.

    Hi,
    I had similar requirement wherein I was supposed to display different data using 2 different internal tables on a subscreen area.
    The screen consists of two parts: 1) selection-screen with few input fields and two buttons 2) Subscreen area where the report need to be displayed. This report is displayed based on the button that the user is selecting. For this I have done the following things:
    1. Capture the sy-ucomm when user is clicking on any of the two buttons in PAI. Then perform data fetch operation.
             MODULE USER_COMMAND_9003 INPUT.
                 CASE OK_CODE.
                     WHEN 'DETAIL'.
                       GV_RPT = OK_CODE.
                       PERFORM F_GET_DETAIL_DATA.
                     WHEN 'REPORT'.
                       GV_RPT = OK_CODE.
                       PERFORM F_GET_REPT_DATA.
                   ENDCASE.
             ENDMODULE.                 " USER_COMMAND_9003  INPUT
    2.  Declare two different ALV's with the fieldcat similar to 2 internal tables respectively. Use the above sy-ucomm PBO to call appropriate ALV.
             MODULE DISPLAY_ALV OUTPUT.
               IF GV_RPT EQ 'DETAIL'.
                 PERFORM F_FIELDCAT_DETAIL.
                 PERFORM F_LAYOUT_DETAIL.
                 PERFORM F_EXCLUDE_TOOLBAR_DETAIL.
                 PERFORM F_DISPLAY_ALV_DETAIL.
               ELSEIF GV_RPT EQ 'REPORT'.
                 PERFORM F_FIELDCAT_REPT.
                 PERFORM F_LAYOUT_REPT.
                 PERFORM F_EXCLUDE_TOOLBAR_REPT.
                 PERFORM F_DISPLAY_ALV_REPT.
               ENDIF.
             ENDMODULE.                 " DISPLAY_ALV  OUTPUT
    3. Before displaying ALV you need to free the container and ALV.
    FORM F_DISPLAY_ALV_DETAIL .
    IF GC_CONTAINER_ES IS NOT INITIAL.
        CALL METHOD GC_CONTAINER_ES->FREE
          EXCEPTIONS
            CNTL_ERROR        = 1
            CNTL_SYSTEM_ERROR = 2
            OTHERS            = 3.
        IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      IF GC_ALV_GRID_ES IS NOT INITIAL.
        CALL METHOD GC_ALV_GRID_ES->FREE
          EXCEPTIONS
            CNTL_ERROR        = 1
            CNTL_SYSTEM_ERROR = 2
            OTHERS            = 3.
        IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      IF GC_CONTAINER_TB IS NOT INITIAL.
        CALL METHOD GC_CONTAINER_TB->FREE
          EXCEPTIONS
            CNTL_ERROR        = 1
            CNTL_SYSTEM_ERROR = 2
            OTHERS            = 3.
        IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      IF GC_ALV_GRID_TB IS NOT INITIAL.
        CALL METHOD GC_ALV_GRID_TB->FREE
          EXCEPTIONS
            CNTL_ERROR        = 1
            CNTL_SYSTEM_ERROR = 2
            OTHERS            = 3.
        IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
      CREATE OBJECT GC_CONTAINER_ES
        EXPORTING
          CONTAINER_NAME              = 'CC_9003'
        EXCEPTIONS
          CNTL_ERROR                  = 1
          CNTL_SYSTEM_ERROR           = 2
          CREATE_ERROR                = 3
          LIFETIME_ERROR              = 4
          LIFETIME_DYNPRO_DYNPRO_LINK = 5
          OTHERS                      = 6.
      CREATE OBJECT GC_ALV_GRID_ES
        EXPORTING
          I_PARENT          = GC_CONTAINER_ES
        EXCEPTIONS
          ERROR_CNTL_CREATE = 1
          ERROR_CNTL_INIT   = 2
          ERROR_CNTL_LINK   = 3
          ERROR_DP_CREATE   = 4
          OTHERS            = 5.
      CALL METHOD GC_ALV_GRID_ES->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IS_LAYOUT                     = GS_LAYOUT_ES
          IT_TOOLBAR_EXCLUDING          = GT_TOOLBAR_ES
        CHANGING
          IT_OUTTAB                     = GT_ES_REPT
          IT_FIELDCATALOG               = GT_FIELDCAT_ES
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
    ENDFORM.                    " F_DISPLAY_ALV_DETAIL
    Similarly define the FORM F_DISPLAY_ALV_REPT.     
    Hope this will be useful for you. If you have any more queries let me know.

Maybe you are looking for

  • Remove attachments from MS Ooutlook converted file

    I have converted MS Outlook e-mails to a Adobe Acrobat X file.  Unfortunately, I set my preferences too late and have all the attachments in the final portfolio, which considerably adds to the size of the file.  I know I can go into each e-mail, clic

  • Outlook 2013 shared mailbox indexing and search issue

    I have 2 Outlook 2013 clients running in Cached Mode, with Download Shared Folders checked and a delegated mailbox opened via the Account Settings Advanced tab. Both clients are accessing the same delegated mailbox. According to this article (http://

  • SQL Query to detect Oracle version

    Hello, For our application, we need to programmatically detect the version of the Oracle instance. Can someone please tell me if there is any SQL query I can run to get the version information? Thank you in advance for enlightening me. Pradeep

  • Installation troubles on Oracle 10g

    I got an error message when installing Oracle 10g: Failure initializating OCR. That was not a problem to finish the installation, but after that I noticed that the OracleCSService service (C:\oracle\product\10.1.0\db_1\bin\ocssd.exe service) was not

  • JAXB generation and XSD choice serious issue

    Helo, Im developing a webservice that uses XSD Choice structure. Unfortunately, this must to done with choice because doesnt make sense using sequences this case. Ill explain bug using this link: http://bdoughan.blogspot.com/2011/04/xml-schema-to-jav