Skip to end of metadata
Go to start of metadata

Interactive report Using SY-LSIND in SAP ABAP

 

report  zinteractive_rep1 no standard page heading line-count 15(2).
data : it_spfli type table of spfli,
         wa_spfli type spfli.
select-options : p_carrid for wa_spfli-carrid.
start-of-selection.
  select * from spfli into table it_spfli where carrid in p_carrid.
end-of-selection.
  loop at it_spfli into wa_spfli.
    write :/ wa_spfli-carrid,
             wa_spfli-connid,
             wa_spfli-countryfr,
             wa_spfli-countryto,
             wa_spfli-cityfrom,
             wa_spfli-cityto,
             wa_spfli-airpfrom,
             wa_spfli-airpto.
  endloop.
top-of-page.
  write :/ 'flight details'.
  uline.
end-of-page.
  write :/ 'thanks visit again'.
  uline.
at line-selection. " event triggers when user double clicks on the basic list
  case sy-lsind. " sy-lsind - list index system variable
    when '1'.
      write :/ 'this is secondary list number =', sy-lsind.
    when '2'.
      write :/ 'this is secondary list number =', sy-lsind.
  endcase.
top-of-page during line-selection.
  case sy-lsind.
    when '1'.
      write :/ 'details from sflight table'.
    when '2'.
      write :/ 'details from sbook table'.
  endcase.
  uline.

Interactive Report with HIDE

 

report  zinteractive_rep2 no standard page heading line-count 15(2).
data : it_spfli type table of spfli,
         wa_spfli type spfli.
data : it_sflight type table of sflight,
         wa_sflight type sflight.
select-options : p_carrid for wa_spfli-carrid.
start-of-selection.
  select * from spfli into table it_spfli where carrid in p_carrid.
end-of-selection.
  loop at it_spfli into wa_spfli.
    write :/ wa_spfli-carrid,
             wa_spfli-connid,
             wa_spfli-countryfr,
             wa_spfli-countryto,
             wa_spfli-cityfrom,
             wa_spfli-cityto,
             wa_spfli-airpfrom,
             wa_spfli-airpto.
    hide : wa_spfli-carrid. " hiding value of carrid in the hide Area
  endloop.
top-of-page.
  write :/ 'details from spfli table'.
  uline.
end-of-page.
  write :/ 'thanks visit again'.
  uline.
at line-selection. " event triggers when the user double clicks on the basic list
  case sy-lsind.
    when '1'.
  select * from sflight into table it_sflight where carrid = wa_spfli-carrid.
   if it_sflight is not initial.
     loop at it_sflight into wa_sflight.
       write :/ wa_sflight-carrid,
                wa_sflight-connid,
                wa_sflight-fldate,
                wa_sflight-price,
                wa_sflight-seatsmax,
                wa_sflight-seatsocc.
       endloop.
     endif.
  endcase.
top-of-page during line-selection.
  case sy-lsind.
    when '1'.
      write :/ 'details from sflight table'.
  endcase.
  uline.

Interactive Report using  SY-LISEL 

 

REPORT  YSP_0123 NO STANDARD PAGE HEADING.
DATA : IT_VBAK TYPE TABLE OF VBAK,
       WA_VBAK TYPE VBAK,
       IT_VBAP TYPE TABLE OF VBAP,
       WA_VBAP TYPE VBAP.
SELECT-OPTIONS : S_VBELN FOR WA_VBAK-VBELN.
DATA : D_VBELN TYPE VBELN.
START-OF-SELECTION.
SELECT * FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN S_VBELN.
SORT IT_VBAK BY VBELN.
END-OF-SELECTION.
LOOP AT IT_VBAK INTO WA_VBAK.
WRITE : /1 WA_VBAK-VBELN,
         10 WA_VBAK-ERDAT,
         20 WA_VBAK-ERNAM,
         30 WA_VBAK-NETWR,
         40 WA_VBAK-ANGDT.
ENDLOOP.
AT LINE-SELECTION.
IF SY-LSIND = 1.
WRITE : / 'INTERACTIVE LIST', SY-LISEL. " sy-lisel - holds the content of the line on which the user double clicked on the basic list
D_VBELN = SY-LISEL+0(4).
SELECT * FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = D_VBELN.
IF SY-SUBRC = 0.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE : /1 WA_VBAP-VBELN,
         10 WA_VBAP-POSNR,
         20 WA_VBAP-MATNR,
         30 WA_VBAP-MATKL.
ENDLOOP.
ENDIF.