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: 

Field-Symbols in ALV

Former Member
0 Kudos
84

Hi

I am using field symbols in report.

Simple output screen is displayed but I want output in ALV.


      ASSIGN itab-f_new(itab-outlen) TO <f_new>.
      WRITE: / text-023, <f_old>.
      WRITE:   text-024, <f_new>.

pls suggest how to convert this in ALV.

Regards.

8 REPLIES 8

Former Member
0 Kudos
59

Hi,

The same way, u create a dynamic internal table using field symbols and field catalogue and pass it to ALV.

We can use field symbols for creating tables and passing to ALV.

  • Method to create dynamic table.

if not i_fldcat[] is initial.

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = i_fldcat[]

importing

ep_table = i_table

exceptions

generate_subpool_dir_full = 1

others = 2

.

assign i_table->* to <i_output>.

create data fs_line like line of <i_output>.

assign fs_line->* to <fs_output>.

Venkat.

0 Kudos
59

Thanks for reply Venkat.

Can you me some more ideas according to my code snippet?

former_member226203
Active Contributor
0 Kudos
59

declare dynamic internal table.and populate it.and to display in a grid use

CALL METHOD w_grid->set_table_for_first_display

EXPORTING

i_structure_name = w_tabname

CHANGING

it_outtab = <t_itab>.

0 Kudos
59

hi

there are 2 field-symbols, so i have to use FM 2 times?

Regards.

0 Kudos
59

Hi

I want to change this code to ALV format.

Please suggest some hints..



TABLES: dd04t,
        cdhdr,
        cdpos,
        dd03l,
        dd41v,
        t685t,
        vbpa,
        tpart,
        konvc,
        ekko.

SELECT-OPTIONS: xudate FOR cdhdr-udate,
                xname  FOR cdhdr-username,
                xebeln FOR ekko-ebeln,
                xlifnr FOR ekko-lifnr.


DATA: wflag,
      wchangenr LIKE cdhdr-changenr.

DATA: indtext(60) TYPE c.

DATA: BEGIN OF icdhdr OCCURS 50.
        INCLUDE STRUCTURE cdhdr.
DATA: END OF icdhdr.

DATA: BEGIN OF icdshw OCCURS 50.
        INCLUDE STRUCTURE cdshw.
DATA: END OF icdshw.

DATA: BEGIN OF ekkey,
        ebeln LIKE eket-ebeln,
        ebelp LIKE eket-ebelp,
        etenr LIKE eket-etenr,
      END OF ekkey.

DATA: BEGIN OF itab OCCURS 50,
        BEGIN OF ekkey,
          ebeln LIKE eket-ebeln,
          ebelp LIKE eket-ebelp,
          etenr LIKE eket-etenr,
        END OF ekkey,

        changenr LIKE cdhdr-changenr,
        udate    LIKE cdhdr-udate,
        utime    LIKE cdhdr-utime,
        username LIKE cdhdr-username,
        chngind  LIKE cdshw-chngind,
        ftext    LIKE cdshw-ftext,
        outlen   LIKE cdshw-outlen,
        f_old    LIKE cdshw-f_old,
        f_new    LIKE cdshw-f_new,
      END OF itab.

DATA: old_objectid LIKE cdhdr-objectid.

FIELD-SYMBOLS: <f_old>, <f_new>.

*------------------------------------------------------------
* TOP-OF-PAGE.
WRITE:/ sy-datum,sy-uzeit,
       50 'P U R C H A S E  O R D E R   H I S T O R Y'.
WRITE: / sy-repid,
         60 'Purchase Orders Changes'.
SKIP.
ULINE.

WRITE:/001 'Change Date',
       016 'Time',
       026 'User Name',
       038 'PO No',
       054 'Item',
       059 'Sch No',
       068 'Old',
       090 'New',
       120 'Text'.

ULINE.

*--------------------------------------------

SELECT * FROM ekko WHERE ebeln IN xebeln AND
                         lifnr IN xlifnr.
  CLEAR cdhdr.
  CLEAR cdpos.
  cdhdr-objectclas = 'EINKBELEG'.
  cdhdr-objectid   = ekko-ebeln.
  PERFORM getchgdocs.
ENDSELECT.


SORT itab BY udate ekkey-ebeln changenr ekkey-ebelp
             ekkey-etenr.


LOOP AT itab.
  CLEAR: indtext, ekkey.
  CASE itab-chngind.
    WHEN 'U'.
      indtext(50) = itab-ftext.
      indtext+51  = text-020.
      CONDENSE indtext.
    WHEN 'D'.
      indtext = text-021.
    WHEN 'E'.
      indtext(5) = itab-ftext.
      indtext+51 = text-021.
      CONDENSE indtext.
    WHEN 'I'.
      indtext = text-022.
  ENDCASE.
  RESERVE 4 LINES.
  IF wchangenr NE itab-changenr.
    wchangenr = itab-changenr.
    ekkey = itab-ekkey.
    WRITE:/ itab-udate UNDER 'Change Date',
            itab-utime UNDER 'Time',
            itab-username UNDER 'User Name',
            itab-ekkey-ebeln UNDER 'PO No',
            itab-ekkey-ebelp UNDER 'Item',
            itab-ekkey-etenr UNDER 'Sch No',
            indtext     UNDER 'Text'.
  ELSEIF itab-ekkey NE ekkey.
    WRITE: itab-ekkey-ebelp UNDER 'Item',
            itab-ekkey-etenr UNDER 'Sch No',
            indtext     UNDER 'Text'.
  ENDIF.

  CASE itab-chngind.
    WHEN 'U'.
      ASSIGN itab-f_old(itab-outlen) TO <f_old>.
      ASSIGN itab-f_new(itab-outlen) TO <f_new>.

      itab-f_old = <f_old>.
      itab-f_new = <f_new>.

      WRITE:  text-023 , itab-f_old UNDER 'Old'.
      WRITE:  text-024, itab-f_new UNDER 'New'.

    WHEN 'E'.
      ASSIGN itab-f_old(itab-outlen) TO <f_old>.
      itab-f_old = <f_old>.
      WRITE: text-023, itab-f_old UNDER 'Old'.

  ENDCASE.

ENDLOOP.


*&---------------------------------------------------------------------*
*&      Form  GETCHGDOCS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM getchgdocs.
  CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
    EXPORTING
      date_of_change    = cdhdr-udate
      objectclass       = cdhdr-objectclas
      objectid          = cdhdr-objectid
      time_of_change    = cdhdr-utime
      username          = cdhdr-username
    TABLES
      i_cdhdr           = icdhdr
    EXCEPTIONS
      no_position_found = 1
      OTHERS            = 2.

  CHECK sy-subrc EQ 0.
  DELETE icdhdr WHERE change_ind EQ 'I'.
  CHECK NOT icdhdr[] IS INITIAL.
  LOOP AT icdhdr.
    CHECK icdhdr-udate IN xudate.
    CHECK icdhdr-username IN xname.
    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
      EXPORTING
        changenumber      = icdhdr-changenr
      IMPORTING
        header            = cdhdr
      TABLES
        editpos           = icdshw
      EXCEPTIONS
        no_position_found = 1
        OTHERS            = 2.
    CHECK sy-subrc EQ 0.
    LOOP AT icdshw.
      CHECK icdshw-text_case EQ space.
      MOVE-CORRESPONDING icdshw TO itab.
      MOVE-CORRESPONDING icdhdr TO itab.
      MOVE icdshw-tabkey+3 TO itab-ekkey.
      APPEND itab.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    "GETCHGDOCS

0 Kudos
59

hi boss,

you are appending all the values to itab, and if it is the final internal table to display.....then declare fieldcatalog and use the fm REUSE_ALV_GRID_DISPLAY.

fieldcatalog samle...

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-reptext_ddic = 'Material Number'.

append wa_fieldcat to it_fieldcat.

clear wa_fieldcat.

0 Kudos
59

Any Suggestions?

Former Member
0 Kudos
59

Hi,

You have to use TOP_OF_PAGE Event and Field Catalog and using REUSE_ALV_GRID to display your output.

In se38, type BCALV_* and press F4 and see.

You can get sample programs.and you can decide whichever way you the output.