Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8735

Insert ROW in ALV List

$
0
0

Hi Experts,

 

I have a requirement to do something like this:

CountProviderDate ConductedExpenses
Start DateEnd DateFareMisc
1Acel1/21/20131/21/20131025
2Acel1/25/20132/25/20131560
January2585
1ASEP5/26/20135/26/20131855
May1855
1BK9/4/20139/4/2013289
September289

 

How can i insert a ROW inside the ALV, wherein the part of the month and the total of each expenses are the one im supposed to insert in ALV LIST.

 

AS of now, Here is the partial code that i have done.

*Check image for the output.

 

REPORT  ZHCM_TRAININGEXPENSE.

 

TYPE-POOLS: sdydo, icon, slis.

 

DATA:

       x_fieldcat  TYPE slis_fieldcat_alv,

       it_fieldcat TYPE slis_t_fieldcat_alv,

       l_layout    TYPE slis_layout_alv,

       x_events    TYPE slis_alv_event,

       it_events   TYPE slis_t_event.

 

DATA:

       BEGIN OF it_alv OCCURS 0,

         count type i,

         provider LIKE hrp1000-stext,

         title LIKE hrp1000-stext,

         startdate LIKE hrp1036-begda,

         enddate LIKE hrp1036-endda,

         Classi LIKE hrp1000-stext,

         agree TYPE hrp1000-stext, "no value in specs

         seminar LIKE hrp1036-price,

         mgtfee LIKE hrp1036-price001,

         meal LIKE hrp1036-price002,

         accomodation LIKE hrp1036-price003,

         fare LIKE hrp1036-price004,

         misc LIKE hrp1036-price005,

         grad LIKE hrp1036-price005,

         amtph LIKE hrp1036-price005,

         total LIKE hrp1036-price005,

       END OF it_alv.

 

DATA: BEGIN OF it_range OCCURS 0,

       begda TYPE hrp1000-begda,

       stext TYPE hrp1000-stext,

       objid TYPE hrp1000-objid,

       COUNT type i.

DATA: END OF it_range.

DATA: wa_range LIKE it_range.

 

DATA: count TYPE i,

      gv_prov TYPE string.

 

 

SELECTION-SCREEN COMMENT /1(50) text1.

PARAMETERS curdate TYPE sy-datum DEFAULT sy-datum.

SELECT-OPTIONS date FOR sy-datum.

 

AT SELECTION-SCREEN OUTPUT.

   text1 = 'Training Expense by Training Provider'.

   date = sy-datum.

 

START-OF-SELECTION.

   PERFORM get_data.

   PERFORM show_alv.

 

*&---------------------------------------------------------------------*

*&      Form  get_data

*&---------------------------------------------------------------------*

*       text

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

FORM get_data.

   SELECT begda stext objid

       INTO CORRESPONDING FIELDS OF TABLE it_range

       FROM  HRP1000

       WHERE begda BETWEEN date-low and date-high

       AND ( otype = 'O' OR otype = 'U' ) ORDER BY stext ASCENDING.

 

   LOOP AT it_range INTO wa_range.

     IF wa_range-begda NE '00000000'.

       IF wa_range-stext NE gv_prov.

         clear count.

         clear gv_prov.

       ENDIF.

 

       count = count + 1.

 

       it_alv-count = count.

       it_alv-provider = wa_range-stext.

 

       SELECT begda "<--- START DATE

         into it_alv-startdate

         FROM HRP1036

         where objid = wa_range-objid.

       ENDSELECT.

 

       SELECT endda "<--- END DATE

         into it_alv-enddate

         FROM HRP1036

         where objid = wa_range-objid.

       ENDSELECT.

 

 

 

       APPEND it_alv. CLEAR it_alv.

       gv_prov = wa_range-stext.

     ENDIF.

   ENDLOOP.

ENDFORM.                    "get_data

 

*&---------------------------------------------------------------------*

*&      Form  show_alv

*&---------------------------------------------------------------------*

*       text

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

FORM show_alv.

   x_fieldcat-fieldname = 'COUNT'.

   x_fieldcat-seltext_l = 'COUNT'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 1.

   x_fieldcat-outputlen = '10'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'PROVIDER'.

   x_fieldcat-seltext_l = 'Provider'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 2.

   x_fieldcat-outputlen = '34'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'TITLE'.

   x_fieldcat-seltext_l = 'Title'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 3.

   x_fieldcat-outputlen = '34'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'STARTDATE'.

   x_fieldcat-seltext_l = 'StartDate'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 4.

   x_fieldcat-outputlen = '12'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'ENDDATE'.

   x_fieldcat-seltext_l = 'Enddate'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 5.

   x_fieldcat-outputlen = '12'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'CLASSI'.

   x_fieldcat-seltext_l = 'CLASSI'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 6.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'AGREE'.

   x_fieldcat-seltext_l = 'Agree'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 7.

   x_fieldcat-outputlen = '20'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'SEMINAR'.

   x_fieldcat-seltext_l = 'SEMINAR'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 8.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'MGTFEE'.

   x_fieldcat-seltext_l = 'MGTFEE'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-outputlen = '17'.

   x_fieldcat-col_pos = 9.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'MEAL'.

   x_fieldcat-seltext_l = 'MEAL'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 10.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'ACCOMODATION'.

   x_fieldcat-seltext_l = 'Accomodation'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 11.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'FARE'.

   x_fieldcat-seltext_l = 'Fare'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 12.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'MISC'.

   x_fieldcat-seltext_l = 'Misc'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 13.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'GRAD'.

   x_fieldcat-seltext_l = 'Grad'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 14.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'AMTPH'.

   x_fieldcat-seltext_l = 'Amtph'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 15.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

   x_fieldcat-fieldname = 'TOTAL'.

   x_fieldcat-seltext_l = 'Total'.

   x_fieldcat-tabname = 'it_alv'.

   x_fieldcat-col_pos = 16.

   x_fieldcat-outputlen = '17'.

   APPEND x_fieldcat TO it_fieldcat.

   CLEAR x_fieldcat.

 

*<---------------------------------->

   x_events-name = slis_ev_top_of_page.

   x_events-form = 'TOP_OF_PAGE'.

   APPEND x_events TO it_events.

   CLEAR x_events.

 

   l_layout-no_colhead = 'X'.

 

   CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

     EXPORTING

       i_callback_program = sy-repid

       is_layout          = l_layout

       it_fieldcat        = it_fieldcat

       it_events          = it_events

     TABLES

       t_outtab           = it_alv

     EXCEPTIONS

       program_error      = 1

       OTHERS             = 2.

   IF sy-subrc NE  0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

ENDFORM.                    "show_alv

 

*&---------------------------------------------------------------------*

*&      Form  TOP_OF_PAGE

*&---------------------------------------------------------------------*

*       text

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

FORM top_of_page.

 

*-To display the headers for main list

 

   WRITE 'Training Report - Expenses'.

   WRITE /'As of'.

   WRITE curdate.

   write /.

 

   FORMAT COLOR COL_HEADING.

   WRITEsy-uline.

 

   WRITE: / sy-vline,

   (8) ' ' ,

   sy-vline,

   (32) ' ' ,

   sy-vline,

   (32) ' ' ,

   sy-vline,

   (23) 'Date Conducted'(015)," CENTERED,

   sy-vline,

   (15) ' ' ,

   sy-vline,

   (18) ' ' ,

   sy-vline,

   (159) 'Expenses'(015)," CENTERED,

   sy-vline.

 

 

   WRITE: / sy-vline,

   (8) 'Count'(013) ,

   sy-vline,

   (32) 'Provider'(014) ,

   sy-vline,

   (32) 'Training Title'(014) ,

   sy-vline,

   (10) 'Start Date'(016) ,

   sy-vline,

   (10) 'End Date'(017) ,

   sy-vline,

   (15) 'Classification'(017) ,

   sy-vline,

   (18) 'Training Agreement'(017) ,

   sy-vline,

 

 

   (15) 'Seminar Cost'(017) ,

   sy-vline,

   (15) 'Management Fee'(017) ,

   sy-vline,

   (15) 'Meal'(017) ,

   sy-vline,

   (15) 'Accomodation'(017) ,

   sy-vline,

   (15) 'Fare'(017) ,

   sy-vline,

   (15) 'Miscellaneous'(017) ,

   sy-vline,

   (15) 'Total Graduates'(017) ,

   sy-vline,

   (15) 'Amount Per Head'(017) ,

   sy-vline,

   (15) 'TOTAL'(017) ,

   sy-vline.

 

 

ENDFORM.                    "TOP_OF_PAGE

 

Thanks.


Viewing all articles
Browse latest Browse all 8735

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>