In the ALV Grid display report we can colour one
particular line (condition based) and also we can BOLD text. In the following
example we are showing PO list with quantity calculation list. We have Sub
Total line (colour = yellow & BOLD text) and Similar kind of Grand Total
line. Here we have the output table structure as follows.
TYPES: BEGIN OF ty_out,
ebeln TYPE char15,
ebelp TYPE char5,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
color TYPE char4,
bold TYPE lvc_t_styl,
END OF ty_out.
ebeln TYPE char15,
ebelp TYPE char5,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
color TYPE char4,
bold TYPE lvc_t_styl,
END OF ty_out.
Here we have a field of colour of 4 character types &
BOLD field of table lvc_t_styl type. This table is a sorted internal table and
we insert style field with value ‘00000121’. Here we are using the function - REUSE_ALV_GRID_DISPLAY_LVC
and Field catalogue type is lvc_t_fcat & Layout type is lvc_s_layo.
REPORT zsr_test NO STANDARD PAGE HEADING.
TABLES: ekko.
TYPE-POOLS: slis.
DATA: wa_fcat TYPE lvc_s_fcat,
it_fcat TYPE lvc_t_fcat,
wa_layout TYPE lvc_s_layo,
wa_top TYPE slis_listheader,
it_top TYPE slis_t_listheader.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
aedat TYPE ekko-aedat,
END OF ty_ekko.
DATA: wa_ekko TYPE ty_ekko,
it_ekko TYPE TABLE OF ty_ekko.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
END OF ty_ekpo.
DATA: wa_ekpo TYPE ty_ekpo,
it_ekpo TYPE TABLE OF ty_ekpo.
TYPES: BEGIN OF ty_out,
ebeln TYPE char15,
ebelp TYPE char5,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
color TYPE char4,
bold TYPE lvc_t_styl,
END OF ty_out.
DATA: wa_out TYPE ty_out,
it_out TYPE TABLE OF ty_out.
INITIALIZATION.
SELECT-OPTIONS s_aedat FOR ekko-aedat.
START-OF-SELECTION.
PERFORM get_ekko.
PERFORM get_ekpo.
END-OF-SELECTION.
PERFORM prepare_output.
PERFORM field_catalog.
PERFORM alv_grid_display.
TOP-OF-PAGE.
PERFORM top_of_page.
*&---------------------------------------------------------------------*
*& Form GET_EKKO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_ekko .
SELECT ebeln aedat FROM ekko
INTO TABLE it_ekko
WHERE aedat IN s_aedat.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_EKPO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_ekpo .
IF it_ekko IS NOT INITIAL.
SELECT ebeln ebelp matnr werks menge meins
FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln
AND matnr NE ' '.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PREPARE_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM prepare_output .
DATA: lw_bold TYPE lvc_s_styl,
lt_bold TYPE lvc_t_styl.
IF it_ekpo IS NOT INITIAL.
LOOP AT it_ekpo INTO wa_ekpo.
wa_out-ebeln = wa_ekpo-ebeln.
wa_out-ebelp = wa_ekpo-ebelp.
wa_out-matnr = wa_ekpo-matnr.
SHIFT wa_out-matnr LEFT DELETING LEADING '0'.
wa_out-werks = wa_ekpo-werks.
wa_out-menge = wa_ekpo-menge.
wa_out-meins = wa_ekpo-meins.
APPEND wa_out TO it_out.
CLEAR: wa_out.
AT END OF ebeln.
SUM.
wa_out-ebeln = 'Sub Total'.
wa_out-menge = wa_ekpo-menge.
wa_out-color = 'C200'.
lw_bold-style = '00000121'.
INSERT lw_bold INTO lt_bold INDEX 1.
wa_out-bold = lt_bold.
FREE lt_bold.
APPEND wa_out TO it_out.
CLEAR: wa_out, lw_bold, wa_ekpo.
ENDAT.
AT LAST.
SUM.
wa_out-ebeln = 'Grand Total'.
wa_out-menge = wa_ekpo-menge.
wa_out-color = 'C210'.
lw_bold-style = '00000121'.
INSERT lw_bold INTO lt_bold INDEX 1.
wa_out-bold = lt_bold.
FREE lt_bold.
APPEND wa_out TO it_out.
CLEAR: wa_out, lw_bold, wa_ekpo.
ENDAT.
ENDLOOP.
ENDIF.
FREE it_ekpo.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM field_catalog .
DATA: lv_col TYPE i VALUE 0.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'EBELN'.
wa_fcat-reptext = 'Purchase Order'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'EBELP'.
wa_fcat-reptext = 'Item'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-reptext = 'Material'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-reptext = 'Plant'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-reptext = 'Quantity'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-reptext = 'Unit'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_layout-zebra = 'X'.
wa_layout-cwidth_opt = 'X'.
wa_layout-info_fname = 'COLOR'.
wa_layout-stylefname = 'BOLD'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout_lvc = wa_layout
it_fieldcat_lvc = it_fcat
TABLES
t_outtab = it_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_of_page .
REFRESH it_top.
wa_top-typ = 'H'.
wa_top-info = 'Purchasing List'.
APPEND wa_top TO it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.
TABLES: ekko.
TYPE-POOLS: slis.
DATA: wa_fcat TYPE lvc_s_fcat,
it_fcat TYPE lvc_t_fcat,
wa_layout TYPE lvc_s_layo,
wa_top TYPE slis_listheader,
it_top TYPE slis_t_listheader.
TYPES: BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
aedat TYPE ekko-aedat,
END OF ty_ekko.
DATA: wa_ekko TYPE ty_ekko,
it_ekko TYPE TABLE OF ty_ekko.
TYPES: BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
END OF ty_ekpo.
DATA: wa_ekpo TYPE ty_ekpo,
it_ekpo TYPE TABLE OF ty_ekpo.
TYPES: BEGIN OF ty_out,
ebeln TYPE char15,
ebelp TYPE char5,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
color TYPE char4,
bold TYPE lvc_t_styl,
END OF ty_out.
DATA: wa_out TYPE ty_out,
it_out TYPE TABLE OF ty_out.
INITIALIZATION.
SELECT-OPTIONS s_aedat FOR ekko-aedat.
START-OF-SELECTION.
PERFORM get_ekko.
PERFORM get_ekpo.
END-OF-SELECTION.
PERFORM prepare_output.
PERFORM field_catalog.
PERFORM alv_grid_display.
TOP-OF-PAGE.
PERFORM top_of_page.
*&---------------------------------------------------------------------*
*& Form GET_EKKO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_ekko .
SELECT ebeln aedat FROM ekko
INTO TABLE it_ekko
WHERE aedat IN s_aedat.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_EKPO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_ekpo .
IF it_ekko IS NOT INITIAL.
SELECT ebeln ebelp matnr werks menge meins
FROM ekpo INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln
AND matnr NE ' '.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form PREPARE_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM prepare_output .
DATA: lw_bold TYPE lvc_s_styl,
lt_bold TYPE lvc_t_styl.
IF it_ekpo IS NOT INITIAL.
LOOP AT it_ekpo INTO wa_ekpo.
wa_out-ebeln = wa_ekpo-ebeln.
wa_out-ebelp = wa_ekpo-ebelp.
wa_out-matnr = wa_ekpo-matnr.
SHIFT wa_out-matnr LEFT DELETING LEADING '0'.
wa_out-werks = wa_ekpo-werks.
wa_out-menge = wa_ekpo-menge.
wa_out-meins = wa_ekpo-meins.
APPEND wa_out TO it_out.
CLEAR: wa_out.
AT END OF ebeln.
SUM.
wa_out-ebeln = 'Sub Total'.
wa_out-menge = wa_ekpo-menge.
wa_out-color = 'C200'.
lw_bold-style = '00000121'.
INSERT lw_bold INTO lt_bold INDEX 1.
wa_out-bold = lt_bold.
FREE lt_bold.
APPEND wa_out TO it_out.
CLEAR: wa_out, lw_bold, wa_ekpo.
ENDAT.
AT LAST.
SUM.
wa_out-ebeln = 'Grand Total'.
wa_out-menge = wa_ekpo-menge.
wa_out-color = 'C210'.
lw_bold-style = '00000121'.
INSERT lw_bold INTO lt_bold INDEX 1.
wa_out-bold = lt_bold.
FREE lt_bold.
APPEND wa_out TO it_out.
CLEAR: wa_out, lw_bold, wa_ekpo.
ENDAT.
ENDLOOP.
ENDIF.
FREE it_ekpo.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FIELD_CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM field_catalog .
DATA: lv_col TYPE i VALUE 0.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'EBELN'.
wa_fcat-reptext = 'Purchase Order'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'EBELP'.
wa_fcat-reptext = 'Item'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-reptext = 'Material'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-reptext = 'Plant'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-reptext = 'Quantity'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = 1 + lv_col.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-reptext = 'Unit'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_layout-zebra = 'X'.
wa_layout-cwidth_opt = 'X'.
wa_layout-info_fname = 'COLOR'.
wa_layout-stylefname = 'BOLD'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_grid_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout_lvc = wa_layout
it_fieldcat_lvc = it_fcat
TABLES
t_outtab = it_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top_of_page .
REFRESH it_top.
wa_top-typ = 'H'.
wa_top-info = 'Purchasing List'.
APPEND wa_top TO it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.
Output is:
63 comments:
Nice Post...Thanks For useful information
http://saponlineguides.blogspot.in/
Thanks for sharing the valuable information here. So i think i got some useful information with this content. Thank you and please keep update like this informative details.
SAP Training in Chennai
SAP ABAP Training in Chennai
Thank you. sir, Really I like your post on sap training videos
This article is really contains lot more information. sapvideos
Thank you for giving this best information. It’s a very nice topic..Sap videos
Thank you. sir, Really I like your post on. sap training videos
Thank you for giving this best information. It’s a very nice topic. sap videos tutorials
I get a lot of great information from this blog. sap training videos
Thanks for sharing this informative blog..Your blog is really useful for me. sapvideos
The information you have given here is truly helpful to me..sap video tutorials
it has great information it is very useful Post. sap videos
I get a lot of great information from this blog..sap video tutorials
Thank you for Sharing Great Information. It is Very Helpful Information on.sapvideos
Thank you for giving this best information. It’s a very nice topic. sap training videos
Thanks for sharing this informative blog..Your blog is really useful for me. sap video training
It was so nice article Thank you for valuable information. sap videos
it has great information it is very useful Post. sap video tutorials
Fabulous..!!! The information you Provided is much useful. sap videos online
Well it Was Very Good Information. Thanks for sharing this Information..Sap videos
It was so nice article.I was really satisfied by seeing this article. sap videos
Fabulous..!!! The information you Provided is much useful. sapvideos
I get a lot of great information from this blog on. sap training videos
Thanks for the detailed info about SAP. sap video training
Thanks for sharing this informative blog..Your blog is really useful for me. sapvideos
Thank you for giving this best information. It’s a very nice topic. sap videos online
Thanks for the detailed info about SAP. sap training videos
Thank you for giving this best information. It’s a very nice topic. sap video training
Thanks for sharing this informative blog..Your blog is really useful for me. sap training videos
Thanks for Nice and Informative Post on. sapvideos
it has great information it is very useful Post. Sap videos
I am very grateful to you that you share very informative post with ussap videos tutorials
Well, I found this information really useful. Thanks a ton for this. sapvideos
I get a lot of great information from this blog on. sap videos online
Fabulous..!! Thank you.The information you provided is much usful information on sap training videos.
Thanks for Nice and Informative Post on Sap videos
It was so nice article.I was really satisified by seeing this article sap hana videos.
This article is really contains lot more information. sap training videos
Thank you. It is such a wonderful post. it has great information it is very useful for sap s4 hana training videos.
Thankyou for Sharing Great Information. It is Very Helpful Information on sap training videos free download.
Thank you. It is such a wonderful post. it has great information it is very useful for sap training videos free download.
Useful Information, your blog is sharing unique information....
Thanks for sharing!!!
SAP Consulting Services in usa
sas value added reseller
This is very useful information.Thanks for sharing with us it was nice SAP article
Thanks for sharing this Informative content. Well explained.
SAP ABAP Training institute in Noida
This paragraph gives clear idea for the new viewers of blogging, Thanks you.
SAP Training in Gurgaon
Thanks for sharing great post !!
This information you provided in the blog that is unique.I love it. Keep continue..
SAP online training | Best sap institute in India
sap hana online training
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
sas implementation services in north america
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
sas implementation services in north america
Worthful Sap Hana tutorial. Appreciate a lot for taking up the pain to write such a quality content on Sap Hana course. Just now I watched this similar -Sap Hana tutorial and I think this will enhance the knowledge of other visitors for sure. Thanks anyway.https://www.youtube.com/watch?v=PGE7A2kHw8Q
thank you for sharing nyce information really very nice sap-pp online classes
hi, Nice post such a valuable information and well explained.
SAP Training institute in hyderabad
All SAP Modules
wow really superb you had posted one nice information through this. Definitely it will be useful for many people. So please keep update like this.sap hr abap online classes
Thank you for sharing this blog spa abap means advanced business application program for more details visit click here
Thank you for sharing this blog Java means advanced business application program for more details about visit click here
Thanks for sharing nice information do visit us at
SAP ABAP Training in Texas>
Hi, it was nice to read this Blog. Thanks for sharing a available informationSAP Basis Training in Irving
This post is really nice and informative. The explanation given is really comprehensive and informative..sap-mm training
These are questions I faced in one of the Interview. If u find any Solution with Coding please let me Know..
1. I have 100 records in a table, how can i simultaneously Delete the 5th, 10th, 15th, 20th......records , write a code for it
2. I have 10000 records, in that How can we sort records in Desending order and search 5005th record details....which is the best method to search it?
3. what do you mean by Update- Function Module, How it is different from Normal and Remote Enabled Function Module...
4. details about Scheduling...
Awesome post presented by you..your writing style is fabulous and keep updated with your blogs
Tally ERP Training in Hyderabad
Thanks for sharing this informative blog post. Nice video. easy to understand, really helpful for learning testing.
Machine Learning Training in Hyderabad
This post is really nice and informative. The explanation given is really comprehensive and informative..sap hr abap training
"Are you need Server access for SAP All modules Contact now and know the Unbelievable offers on Server Access for SAP All modules.
Grab the Special Offers and Discounts. One time payment available it gets more benefits.
Visit Us: www.visionsap.com
Phone No's Calling: +16032623609, Whatsapp: +91 7382121738
Mail ID: info@visionsap.com
#SAPoffers #SAPServerOffers #Specialoffers #Specialdiscounts #Limitedoffer #Hurryup
"
I need the SAP Server access can you help me please?
Great Post. The information provided is of great use as I got to learn new things. Keep Blogging.
SAP ABAP TRAINING IN HYDERABAD"
Post a Comment