Sunday 27 May 2012

CLASSICAL REPORT PROGRAMS

 *****VERY SIMPLE REPORT PROGRAM TO DISPLAY RECORDS FROM SPFLI TABLE*****

REPORT  ZCLASSICAL_REPORT_01 NO STANDARD PAGE HEADING LINE-COUNT 10(2).

types : begin of tab,
        carrid type spfli-carrid,
        connid type spfli-connid,
        countryfr type spfli-countryfr,
        countryto type spfli-countryto,
        cityfrom type spfli-cityfrom,
        cityto type spfli-cityto,
        airpfrom type spfli-airpfrom,
        airpto type spfli-airpto,
        distance type spfli-distance,
        end of tab.

data : it_flight type table of tab,
         wa_flight type tab.

select-options : s_carrid for wa_flight-carrid.
initialization.
s_carrid-low = 'AB'.
s_carrid-HIGH = 'ZZ'.
s_carrid-SIGN = 'I'.
s_carrid-OPTION = 'BT'.
APPEND S_CARRID.

START-OF-SELECTION.
SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE IT_FLIGHT.

  TOP-OF-PAGE.
  WRITE :/50 'DAILY FLIGHT DETAILS OF INDIAN AIRLINES'.
  ULINE.

  END-OF-PAGE.
  WRITE :/50 ' THANK U VISIT AGAIN'.
  ULINE.

  END-OF-SELECTION.
LOOP AT IT_FLIGHT INTO WA_FLIGHT.
  WRITE :/ WA_FLIGHT-CARRID,
           WA_FLIGHT-CONNID,
           WA_FLIGHT-COUNTRYFR,
           WA_FLIGHT-COUNTRYTO,
           WA_FLIGHT-CITYFROM,
           WA_FLIGHT-CITYTO,
           WA_FLIGHT-AIRPFROM,
           WA_FLIGHT-AIRPTO,
           WA_FLIGHT-DISTANCE.
  ENDLOOP.

*****REPORT TO DISPLAY FLIGHT OR MATERIAL DETAILS BASED ON RADIO BUTTON AT SELECTION SCREEN******

report  zclassical_report_02 NO STANDARD PAGE HEADING LINE-COUNT 10(2).
DATA : IT_FLIGHT TYPE TABLE OF SPFLI,
       WA_FLIGHT TYPE SPFLI.

DATA : IT_MATERIAL TYPE TABLE OF MARA,
       WA_MATERIAL TYPE MARA.
selection-screen : begin of block b1 with frame title text-001.
parameters : p_carrid type spfli-carrid.
parameters : p_matnr type mara-matnr.
selection-screen : end  of block b1.

selection-screen : begin of block b2 with frame title text-002.
PARAMETERS : R1  RADIOBUTTON GROUP G1 DEFAULT 'X' USER-COMMAND SS.
PARAMETERS : R2  RADIOBUTTON GROUP G1 .
selection-screen : end  of block b2.

AT SELECTION-SCREEN OUTPUT. " DYNAMIC MODIFICATION OF SCREEN

 IF R1 = 'X'.
 LOOP AT SCREEN.
 IF SCREEN-NAME = 'P_MATNR' OR SCREEN-NAME = '%_P_MATNR_%_APP_%-TEXT'.
          SCREEN-ACTIVE = 0.
          SCREEN-INVISIBLE = 1.
          MODIFY SCREEN.
          ENDIF.
          ENDLOOP.

 ELSEIF R2 = 'X'.
   LOOP AT SCREEN.
   IF SCREEN-NAME = 'P_CARRID' OR SCREEN-NAME = '%_P_CARRID_%_APP_%-TEXT'.
          SCREEN-ACTIVE = 0.
          SCREEN-INVISIBLE = 1.
          MODIFY SCREEN.
          ENDIF.
          ENDLOOP.
  ENDIF.

        INITIALIZATION.
        P_CARRID = 'AB'.
        P_MATNR = '00000010'.

 START-OF-SELECTION.
  IF R1 = 'X'.
  SELECT * FROM SPFLI INTO TABLE IT_FLIGHT UP TO 20 ROWS.
  ELSEIF R2 = 'X'.
  SELECT * FROM MARA INTO TABLE IT_MATERIAL UP TO 20 ROWS.
    ENDIF.

            END-OF-SELECTION.

            IF R1 = 'X'.
              LOOP AT IT_FLIGHT INTO WA_FLIGHT.
                WRITE :/ WA_FLIGHT-CARRID,
                         WA_FLIGHT-CONNID,
                         WA_FLIGHT-COUNTRYFR,
                         WA_FLIGHT-COUNTRYTO,
                         WA_FLIGHT-AIRPFROM,
                         WA_FLIGHT-AIRPTO,
                         WA_FLIGHT-CITYFROM,
                         WA_FLIGHT-CITYTO,
                         WA_FLIGHT-DISTANCE.

                ENDLOOP.
              ELSEIF R2 = 'X'.
                 LOOP AT IT_MATERIAL INTO WA_MATERIAL.
                  WRITE :/ WA_MATERIAL-MATNR,
                           WA_MATERIAL-ERSDA,
                           WA_MATERIAL-ERNAM,
                           WA_MATERIAL-AENAM.

                ENDLOOP.
                ENDIF.

       TOP-OF-PAGE.
     IF R1 = 'X'.
       WRITE :/50 'INDIAN AIRLINE DETAILD OF FLIGHT'.
       ULINE.
       ELSEIF R2 = 'X'.
         WRITE :/50 'DETAILS OF MATERIALS'.
       ULINE.
         ENDIF.

         END-OF-PAGE.
         WRITE :/50 'THANKS FOR SHOWING INTEREST'.
         ULINE.

***REPORT WITH TOP-OF -PAGE & END-OF-PAGE EVENTS*****

REPORT  ZREP_001  no standard page heading line-count 20(2).

data : it_flight type table of sflight,
       wa_flight type sflight.

select-options : s_carrid for wa_flight-carrid.
*select-options : s_carrid for wa_flight-carrid no-extension.
* select-options : s_carrid for wa_flight-carrid no intervals.
initialization.
s_carrid-low = 'AA'.
s_carrid-high = 'ZZ'.
append s_carrid.

start-of-selection.
select * from sflight into table it_flight where carrid in s_carrid.

end-of-selection.
loop at it_flight into wa_flight.
write : /1 wa_flight-carrid,
          10 wa_flight-connid,
          30  wa_flight-fldate,
          50 wa_flight-price left-justified.
endloop.

top-of-page.
write : 'Carrid', 10 'connid', 30 'flight date' , 50 'ticket price'..
uline.

end-of-page.
write : 'jet airline flight details for the month december'.

*******REPORT WITH DYNAMIC MODIFICATION AT SELECTION-SCREEN******

REPORT  ZREP_002                                .

data : it_flight type table of sflight,
         wa_flight type sflight,
         it_mara type table of mara,
         wa_mara type mara.

selection-screen : begin of block b1 with frame title text-000.
parameters : r1 radiobutton group g1 user-command AA default 'X',
             r2 radiobutton group g1 .
parameters : p_carrid type sflight-carrid,
             p_matnr type mara-matnr.
selection-screen : end of block b1.

at selection-screen output.

  if r1 = 'X'.
    loop at screen.

  if screen-name = 'P_MATNR'
  or SCREEN-NAME = '%_P_MATNR_%_APP_%-TEXT'.
        screen-active = 0.
        screen-invisible = 1.

        MODIFY SCREEN.
      endif.

    endloop.
  elseif r2 = 'X'.

    loop at screen.
if screen-name = 'P_CARRID'
OR SCREEN-NAME = '%_P_CARRID_%_APP_%-TEXT'.
  screen-active = 0.
        screen-invisible = 1.
        modify screen.
      endif.
    endloop.
  endif.

*********REPORT TO HIDE SELECT-OPTIONS AT SELECTION-SCREEN******


data : it_flight type table of sflight,
       wa_flight type sflight,
       it_mara type table of mara,
       wa_mara type mara.

selection-screen : begin of block b1 with frame title text-000.
parameters : r1 radiobutton group g1 user-command AA DEFAULT 'X',
                  r2 radiobutton group g1  .
select-options : s_carrid for wa_flight-carrid,
                      s_matnr for wa_mara-matnr.
selection-screen : end of block b1.

at selection-screen output.
  if r1 = 'X'.
    loop at screen.
      if screen-name = '%_S_MATNR_%_APP_%-TEXT' OR
       SCREEN-NAME = '%_S_MATNR_%_APP_%-OPTI_PUSH' OR
       SCREEN-NAME = 'S_MATNR-LOW' OR
       SCREEN-NAME = '%_S_MATNR_%_APP_%-TO_TEXT' OR
       screen-name = 'S_MATNR-HIGH' OR
       SCREEN-NAME = '%_S_MATNR_%_APP_%-VALU_PUSH'.
        screen-active = 0.
        screen-invisible = 1.
        MODIFY SCREEN.
      endif.
    endloop.
  elseif r2 = 'X'.
    loop at screen.
      if screen-name = '%_S_CARRID_%_APP_%-TEXT' OR
       SCREEN-NAME = '%_S_CARRID_%_APP_%-OPTI_PUSH' OR
       SCREEN-NAME = 'S_CARRID-LOW' OR
       SCREEN-NAME = '%_S_CARRID_%_APP_%-TO_TEXT' OR
       screen-name = 'S_CARRID-HIGH' OR
       SCREEN-NAME = '%_S_CARRID_%_APP_%-VALU_PUSH'.
        screen-active = 0.
        screen-invisible = 1.
        modify screen.
      endif.
    endloop.
  endif.

****REPORT USING MODIF-ID TO DYNAMIC HIDE THE PARAMETERS AT SELECTIO-SCREEN ****

data : it_flight type table of sflight,
         wa_flight type sflight,
        it_ekpo type table of ekpo,
        wa_ekpo type ekpo.

selection-screen begin of block b1.

parameters : r1 radiobutton group g1 user-command fg default 'X',
                  r2 radiobutton group g1.
selection-screen uline /1(50).

parameters : p_carrid type sflight-carrid modif id m1,
                   p_connid type sflight-connid modif id m1,
                   p_date type sflight-fldate modif id m1.
selection-screen uline /1(50).

parameters : p_ekjk type ekpo-ebeln modif id m2,
                    p_ebelp type ekpo-ebelp modif id m2,
                   p_adate type ekpo-aedat modif id m2.
selection-screen end of block b1.

at selection-screen output.
************* TRY 1***************
  if r1 = 'X'.
    loop at screen .
      if screen-group1 = 'M2'.
        screen-active = 0.
        screen-invisible = 1.
        modify screen.
      endif.
    endloop.
  elseif r2 = 'X'.
    loop at screen.
      if screen-group1 = 'M1'.
        screen-active = 0.
        screen-invisible = 1.
        modify screen.
      endif.
    endloop.
 endif.

************OR TRY 2*****************
  if r1 = 'X'.
    loop at screen .
      if screen-group1 = 'M2'.
        screen-input = 0.
        modify screen.
      endif.
    endloop.

  elseif r2 = 'X'.
    loop at screen.
      if screen-group1 = 'M1'.
        screen-input = 0.
        modify screen.
      endif.
    endloop.
  endif.

**************OR TRY 3******************
  if r1 = 'X'.
  loop at screen .
     if screen-group1 = 'M2'.
        screen-intensified = 1.
        screen-input = 0.
        modify screen.
      endif.
    endloop.
  elseif r2 = 'X'.
    loop at screen.
      if screen-group1 = 'M1'.
        screen-intensified = 1.
        screen-input = 0.
        modify screen.
      endif.
    endloop.
  endif.


********REPORT WITH CONTROL LEVEL PROCESSING STATEMENTS***********

data : it_flight type table of sflight,
          wa_flight type sflight.

select-options : s_carrid for wa_flight-carrid default 'AA' TO 'ZZ'.

start-of-selection.
select * from sflight into table it_flight where carrid in s_carrid.
  sort it_flight by carrid connid.

  end-of-selection.
  loop at it_flight into wa_flight.
    write :/ wa_flight-carrid,
             wa_flight-connid,
             wa_flight-fldate,
             wa_flight-price,
             wa_flight-seatsmax,
             wa_flight-seatsocc.
    AT END OF CARRID.
      SUM.
      ULINE.
      WRITE :/'END OF CARRID-', WA_FLIGHT-CARRID,'PRICE =',28 WA_FLIGHT-PRICE LEFT-JUSTIFIED.
      ENDAT.
    endloop.
*******REPRT WITH CONTROL LEVEL PROCESSING STAATEMENTS : AT FIRST, AT NEW, AT END OF , AT LAST ******
REPORT  ZREP_009    no standard page heading line-count 27(2).

data : it_flight type table of sflight,
       wa_flight type sflight.

start-of-selection.
select * into table it_flight from sflight .
sort it_flight by carrid connid fldate.
end-of-selection.
loop at it_flight into wa_flight.
at first .
write :/ 'at first printing only once in a report'.
uline.
endat.
at new carrid.
write : / '***begin of new carrid =>', wa_flight-carrid.
endat.
write : /1 wa_flight-carrid,
         10 wa_flight-connid,
         20 wa_flight-fldate,
         40 wa_flight-price left-justified.

at end of carrid.
sum.
uline /1(50).
write : /'sum of price  at end of carrid ', wa_flight-carrid, '=',
wa_flight-price
left-justified.
uline /1(50).
endat.

at last.
write : / 'appears only once at last of report'.
endat.
endloop.

top-of-page.
write : /1 'carrid',
         10 'connid',
         20 'fldate',
         40 'flight-price'.

uline /1(50).
end-of-page.
uline /1(50).
write :/ 'thanks for putting interest'.

 *******Report with event AT SELECTION-SCREEN ON HELP-REQUEST EVENT ******

report  zclassical_report_02 NO STANDARD PAGE HEADING LINE-COUNT 10(2).

TYPES : BEGIN OF LIST,
        CARRID TYPE SPFLI-CARRID,
        END OF LIST.

 DATA  : IT_LIST TYPE TABLE OF LIST.
 DATA  : WA_LIST TYPE  LIST.
DATA : IT_RETURN TYPE TABLE OF DDSHRETVAL.
DATA : WA_RETURN TYPE DDSHRETVAL.

DATA : IT_FLIGHT TYPE TABLE OF SPFLI,
       WA_FLIGHT TYPE SPFLI.

DATA : IT_MATERIAL TYPE TABLE OF MARA,
       WA_MATERIAL TYPE MARA.

DATA : IT_LINKS TYPE TABLE OF TLINE.
selection-screen : begin of block b1 with frame title text-001.
parameters : p_carrid type CHAR3.
parameters : p_matnr type CHAR18.

selection-screen : end  of block b1.


selection-screen : begin of block b2 with frame title text-002.
                  PARAMETERS : R1  RADIOBUTTON GROUP G1 DEFAULT 'X' USER-COMMAND SS.
                  PARAMETERS : R2  RADIOBUTTON GROUP G1 .

selection-screen : end  of block b2.

AT SELECTION-SCREEN OUTPUT. " DYNAMIC MODIFICATION OF SCREEN

    IF R1 = 'X'.
      LOOP AT SCREEN.
        IF SCREEN-NAME = 'P_MATNR'
        OR SCREEN-NAME = '%_P_MATNR_%_APP_%-TEXT'.
          SCREEN-ACTIVE = 0.
          SCREEN-INVISIBLE = 1.
          MODIFY SCREEN.
          ENDIF.
          ENDLOOP.

      ELSEIF R2 = 'X'.
         LOOP AT SCREEN.
        IF SCREEN-NAME = 'P_CARRID'
        OR SCREEN-NAME = '%_P_CARRID_%_APP_%-TEXT'.
          SCREEN-ACTIVE = 0.
          SCREEN-INVISIBLE = 1.
          MODIFY SCREEN.
          ENDIF.
          ENDLOOP.

        ENDIF.

        INITIALIZATION.
        P_CARRID = 'AB'.
        P_MATNR = '00000010'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR P_CARRID.
  call function 'HELP_OBJECT_SHOW'
    exporting
      dokclass                            = 'ABAP'
      dokname                             = 'FLIGHTHELP'
    tables
      links                               = IT_LINKS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CARRID.
  SELECT CARRID FROM SPFLI INTO TABLE IT_LIST.

  call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
      retfield               = 'CARRID'
     VALUE_ORG              = 'S'
    tables
      value_tab              =  IT_LIST
     RETURN_TAB             = IT_RETURN.


LOOP AT IT_RETURN INTO WA_RETURN.
  P_CARRID = WA_RETURN-FIELDVAL.
  ENDLOOP.
        START-OF-SELECTION.
        IF R1 = 'X'.
          SELECT * FROM SPFLI INTO TABLE IT_FLIGHT
          where carrid = p_carrid.
          ELSEIF R2 = 'X'.
            SELECT * FROM MARA INTO TABLE IT_MATERIAL
            where matnr = p_matnr.
            ENDIF.

            END-OF-SELECTION.

            IF R1 = 'X'.
              LOOP AT IT_FLIGHT INTO WA_FLIGHT.
                WRITE :/ WA_FLIGHT-CARRID,
                         WA_FLIGHT-CONNID,
                         WA_FLIGHT-COUNTRYFR,
                         WA_FLIGHT-COUNTRYTO,
                         WA_FLIGHT-AIRPFROM,
                         WA_FLIGHT-AIRPTO,
                         WA_FLIGHT-CITYFROM,
                         WA_FLIGHT-CITYTO,
                         WA_FLIGHT-DISTANCE.

                ENDLOOP.
              ELSEIF R2 = 'X'.
                 LOOP AT IT_MATERIAL INTO WA_MATERIAL.
                  WRITE :/ WA_MATERIAL-MATNR,
                           WA_MATERIAL-ERSDA,
                           WA_MATERIAL-ERNAM,
                           WA_MATERIAL-AENAM.

                ENDLOOP.
                ENDIF.

       TOP-OF-PAGE.
     IF R1 = 'X'.
       WRITE :/50 'INDIAN AIRLINE DETAILD OF FLIGHT'.
       ULINE.
       ELSEIF R2 = 'X'.
         WRITE :/50 'DETAILS OF MATERIALS'.
       ULINE.
         ENDIF.

         END-OF-PAGE.
         WRITE :/50 'THANKS FOR SHOWING INTEREST'.
         ULINE.

6 comments:

Unknown said...
This comment has been removed by the author.
Unknown said...

Your Blog is really a great help to all beginners in ABAP. Thanks a lot Siva for posting all these codes on your blog.... :)

palnati said...

Excellent help for the abap programmers who seeks help

Unknown said...

thanks

prabhakar said...

thanks a lot sir,,,

Unknown said...

Too good

Comments system

Disqus Shortname