Application Development and Automation 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: 
Read only

How to display three months data in ALV grid control

Former Member
0 Kudos
1,741

Hi,

i have tried for displaying three months data month wise data in alv grid controsl.But still data is not displaying month wise.For this i have created one screen and also maintain one custom control in screen layout.in program i have created one data object with reference CL_GUI_DOCKING_CONTAINER.And also created one instance for this class.after that i have splitted continer into three containers using CL_GUI_SPLITTER_CONTAINER.After that i have created objects with reference CL_GUI_CONTAINER.

And also i have created instances for that class.after that i have created data objects with reference CL_GUI_ALV_GRID.

I have created three instances for this class.Because i have to display three months data in containers. for this purpose i have called method SET_TABLE_FOR_FIRST_DISPLAY. But data displaying date wise i need to display three month data in month wise in alv grid control.In this process i have read date also but not displaying three months data in month wise.

please tell me logic.how to display three months data in month wise in alv grid control. for this inputs are plant number and

date range.and more thing table is having date wise data. how can i split data into month wise that is main thing

please tell me logic

Awaiting for your reply,

Thanks & Regards,

Vasu.

17 REPLIES 17
Read only

chundru_ravindra
Participant
0 Kudos
1,353

Hi,

Use this Link: <link to blocked site removed by moderator>

or demo program RSDEMO_SPLITTER_CONTROL

Regards,

Ravindra.

Edited by: Thomas Zloch on Feb 20, 2012

Read only

Former Member
0 Kudos
1,353

Hi,

creat 3 internal table with field month

data:gv_month(02) type numc.

loop at itab(consider) into wa.

use cacs_date_get_year_month. Fm

pass CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year

EXPORTING

i_date = wa_date

IMPORTING

e_month = gv_month

e_year = gv_year

.

case gv_month.

when '01'.

append wa to lit1.(if it not work,use work area of lit1,move correspondind wa to wa_lit1 then append)

when '02'

append wa to lit2.

when '03'.

append wa to lit3.

endcase.

now data is saparated base on month,,,pass this three different table to three different fm(set_table_first_display) ,,,

Thanks

Read only

0 Kudos
1,353

Hi

Thanks for all.I have tried now it is working but as per requirement month name and cumulative total will display like this format.And one more thing month range will change some times means sometimes i will give January date to march date and sometimes i will give July date to October date. but date range is same means between dates range is three months.

please tell me how to display.

GAS PRESSURE WELDING COST EFFECTIVENESS Dec-11 Cummulative

Sr. No Item Unit Rate Qty Amount Qty Amount

GAS PRESSURE WELDING COST EFFECTIVENESS Jan-12

Sr. No Item Unit Rate Qty Amount Qty Amount

GAS PRESSURE WELDING COST EFFECTIVENESS Feb-12

Sr. No Item Unit Rate Qty Amount Qty Amount

Thanks & Regards,

Vasu.

Edited by: vasuabap on Feb 20, 2012 6:21 PM

Edited by: vasuabap on Feb 20, 2012 6:23 PM

Edited by: vasuabap on Feb 20, 2012 6:24 PM

Read only

0 Kudos
1,353

Hi

creat 3 internal table with field month


data:gv_month(02) type numc,
        gv_flag type i default 0.

loop at itab(consider) into wa.

use cacs_date_get_year_month. Fm
pass CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year
EXPORTING
i_date = wa_date
IMPORTING
e_month = gv_month
e_year = gv_year.
if gv_flag ne 1.
gv_prev_month = gv_month.
gv_flag = 1. 
endif.
case gv_month.
when gv_prev_month.
append wa to lit1.(if it not work,use work area of lit1,move correspondind wa to wa_lit1 then append)
when gv_prev_month + 1.
append wa to lit2.
when gv_prev_month + 2.
append wa to lit3.
endcase.

try this logic.

Hope this helps

Aswath.

Read only

0 Kudos
1,353

Hi Aswath,

i have tried your logic but errors are coming means 1 and 2 are not interpret

Thanks & Regards,

Vasu.

Read only

0 Kudos
1,353

Hi Aswath,

when gv_prev_month + 1.

MOVE-CORRESPONDING wa to wa2.

APPEND wa2 to ktab.

when gv_prev_month + 2.

MOVE-CORRESPONDING wa to wa3.

APPEND wa3 to ltab.

these statements are not compling means while program activating in that time program is showing errors.

Thanks & Regards,

Vasu.

Read only

0 Kudos
1,353

Hi,


data:gv_month type ad_monat,      " or use type i if this won't work
         gv_flag type i default 0.
 
loop at itab(consider) into wa.
 
use cacs_date_get_year_month. Fm
pass CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year
EXPORTING
i_date = wa_date
IMPORTING
e_month = gv_month
e_year = gv_year.
if gv_flag ne 1.
gv_prev_month = gv_month.
gv_flag = 1. 
endif.
case gv_month.
when gv_prev_month.
append wa to lit1.(if it not work,use work area of lit1,move correspondind wa to wa_lit1 then append)
when gv_prev_month + 1.
append wa to lit2.
when gv_prev_month + 2.
append wa to lit3.
endcase.

Hey i just changed the type of gv_month try now. It was just not compatible thats it.

Hope you get your answer.

Aswath.

Read only

0 Kudos
1,353

H iAswath,

I have tried your logic but while activating program.it is displaying errors.

this is my program code.can you Please check this code.

&----


*& Report ZMC_PM002_GPW_OOPS1

*&

&----


*&

*&

&----


REPORT zmc_pm002_gpw_oops1.

TABLES:zmcpm_gpw_plnt,zmcpm_gpw_item.

  • SELECTION-SCREEN PARAMETERS

SELECTION-SCREEN BEGIN OF BLOCK b1

WITH FRAME TITLE text-001.

SELECT-OPTIONS:date FOR zmcpm_gpw_item-item_date.

SKIP.

PARAMETERS:plant TYPE zmcpm_gpw_plnt-werks.

SELECTION-SCREEN END OF BLOCK b1.

*FOR HOLDING CONTAINER

DATA:container TYPE REF TO cl_gui_docking_container.

data:gv_month type I.

data:gv_year(04) type c,

gv_flag type i VALUE 0,

gv_prev_month TYPE I.

*DEFINING AN INTERNAL TABLE

TYPES:BEGIN OF ty_fs,

werks TYPE werks_d,

item_no TYPE zqmnum,

item_name TYPE zmcpm_name,

item_unit TYPE meins,

item_type TYPE zmcpm_type,

item_date TYPE erdat,

item_qty TYPE zsmeng,

item_rate TYPE zkwert,

amount TYPE zmcpm_gpw_item-item_rate,

month_no type fcmnr,

month_name TYPE fcltx,

cumulativetotal TYPE zmcpm_gpw_item-item_rate,

END OF ty_fs.

DATA:wa TYPE ty_fs.

DATA:wa1 TYPE ty_fs.

DATA:wa2 TYPE ty_fs.

DATA:wa3 TYPE ty_fs.

DATA:itab TYPE STANDARD TABLE OF ty_fs.

DATA:jtab TYPE STANDARD TABLE OF ty_fs.

DATA:ktab TYPE STANDARD TABLE OF ty_fs.

DATA:ltab TYPE STANDARD TABLE OF ty_fs.

DATA:cumulativetotal TYPE p DECIMALS 2 VALUE 0.

DATA:total1 TYPE p DECIMALS 2 VALUE 0.

DATA:total2 TYPE p DECIMALS 2 VALUE 0.

DATA:total3 TYPE p DECIMALS 2 VALUE 0.

DATA:layout TYPE lvc_s_layo.

*FOR SORTING

DATA:sort_w TYPE lvc_s_sort,

sort_b TYPE lvc_t_sort.

*SPLITTING CONTAINER INTO THREE PARTS

DATA:splitter TYPE REF TO cl_gui_splitter_container.

DATA: year(4) TYPE c,

month(2) TYPE c,

day(2) TYPE c.

DATA:FCAT_WA TYPE LVC_S_FCAT.

DATA:fcat TYPE lvc_t_fcat.

DATA:month_b TYPE STANDARD TABLE OF t247,

month_wa TYPE t247.

  • TRANSFERRING DATA FROM TABLE TO INTERNAL TABLE

BREAK-POINT.

SELECT zmcpm_gpw_plnt~werks

zmcpm_gpw_item~item_no

zmcpm_gpw_item~item_name

zmcpm_gpw_item~item_unit

zmcpm_gpw_item~item_type

zmcpm_gpw_item~item_date

zmcpm_gpw_item~item_qty

zmcpm_gpw_item~item_rate

INTO TABLE itab

FROM zmcpm_gpw_item INNER JOIN zmcpm_gpw_plnt

ON zmcpm_gpw_itemitem_no = zmcpm_gpw_plntitem_no

WHERE werks = plant AND zmcpm_gpw_item~item_date BETWEEN DATE-LOW AND DATE-HIGH.

SELECT spras mnr ktx ltx FROM t247 INTO TABLE month_b WHERE spras = sy-langu.

IF NOT itab IS INITIAL.

SORT itab BY item_no item_date.

ENDIF.

**CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'

    • EXPORTING

    • i_datum_bis = date-low

    • i_datum_von = date-high

      • I_KZ_INCL_BIS = ' '

    • IMPORTING

    • e_monate = month_no.

CLEAR wa.

LOOP AT itab INTO wa.

year = wa-item_date(4).

month = wa-item_date+4(2).

day = wa-item_date+6(2).

wa-amount = wa-item_qty * wa-item_rate.

*CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'

  • EXPORTING

  • I_DATE = wa-item_date

  • IMPORTING

  • E_MONTH = gv_month

  • E_YEAR = gv_year.

  • .

*

*

  • " for reading date

*

*

  • READ TABLE month_b INTO month_wa WITH KEY mnr = month .

*

*case gv_month.

  • when '01'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING wa to wa1.

  • APPEND wa1 to jtab.

*if not jtab is INITIAL.

  • sort jtab by item_no month_no.

  • endif.

  • when '02'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING wa to wa2.

  • APPEND wa2 to ktab.

*if not ktab is INITIAL.

  • sort ktab by item_no month_no.

  • endif.

  • when '03'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING WA TO WA3.

  • APPEND WA3 TO LTAB.

*if not ltab is INITIAL.

  • sort ltab by item_no month_no.

*

*endif.

  • ENDCASE.

CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year

EXPORTING

i_date = wa-item_date

IMPORTING

e_month = gv_month

e_year = gv_year.

if gv_flag ne 1.

gv_prev_month = gv_month.

gv_flag = 1.

endif.

case gv_month.

when GV_PREV_MONTH.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa1-item_no,

wa-item_name to wa1-item_name,

wa-item_unit to wa1-item_unit,

wa-item_qty to wa1-item_qty,

wa-item_rate to wa1-item_rate,

wa-amount to wa1-amount,

wa-month_name to wa1-month_name,

wa-cumulativetotal to wa1-cumulativetotal.

APPEND wa1 to jtab.

if not jtab is INITIAL.

sort jtab by item_no month_name.

endif.

when GV_PREV_MONTH + 1.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa2-item_no,

wa-item_name to wa2-item_name,

wa-item_unit to wa2-item_unit,

wa-item_qty to wa2-item_qty,

wa-item_rate to wa2-item_rate,

wa-amount to wa2-amount,

wa-month_name to wa2-month_name,

wa-cumulativetotal to wa2-cumulativetotal.

APPEND wa2 to ktab.

if not ktab is INITIAL.

sort ktab by item_no month_name.

endif.

when GV_PREV_MONTH + 2.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa3-item_no,

wa-item_name to wa3-item_name,

wa-item_unit to wa3-item_unit,

wa-item_qty to wa3-item_qty,

wa-item_rate to wa3-item_rate,

wa-amount to wa3-amount,

wa-month_name to wa3-month_name,

wa-cumulativetotal to wa3-cumulativetotal.

APPEND WA3 TO LTAB.

if not ltab is INITIAL.

sort ltab by item_no month_name.

endif.

endcase.

ENDLOOP.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

i_structure_name = 'ZMCPM_GPW_PLNT12'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

i_internal_tabname = 'ITAB'

CHANGING

ct_fieldcat = fcat.

sort_w-spos = 1.

sort_w-fieldname = 'ITEM_NO'.

APPEND sort_w TO sort_b .

sort_w-spos = 2.

sort_w-fieldname = 'ITEM_NAME'.

APPEND sort_w TO sort_b .

sort_w-spos = 3.

sort_w-fieldname = 'ITEM_RATE'.

APPEND sort_w TO sort_b .

sort_w-spos = 4.

sort_w-fieldname = 'ITEM_QTY'.

APPEND sort_w TO sort_b.

sort_w-spos = 5.

sort_w-fieldname = 'AMOUNT'.

*SORT_W-SUBTOT = 'X'.

APPEND sort_w TO sort_b.

sort_w-spos = 6.

sort_w-fieldname = 'CUMULATIVETOTAL'.

APPEND sort_w TO sort_b.

sort_w-spos = 7.

sort_w-fieldname = 'MONTH_NAME' .

APPEND sort_w TO sort_b.

IF container IS INITIAL.

CREATE OBJECT container

EXPORTING

  • parent =

repid = sy-repid

dynnr = '2000'

side = container->dock_at_top

extension = 1000

  • style =

  • lifetime = lifetime_default

  • caption =

  • metric = 0

  • ratio =

  • no_autodef_progid_dynnr =

name = 'QUARTERLY REPORT' .

CREATE OBJECT splitter

EXPORTING

  • link_dynnr =

  • link_repid =

  • shellstyle =

  • left =

  • top =

  • width =

  • height =

  • metric = cntl_metric_dynpro

  • align = 15

parent = container

rows = 3

columns = 1.

  • no_autodef_progid_dynnr =

  • name =

DATA:container1 TYPE REF TO cl_gui_container.

DATA:container2 TYPE REF TO cl_gui_container.

DATA:container3 TYPE REF TO cl_gui_container.

DATA:container4 TYPE REF TO cl_gui_container.

CALL METHOD splitter->get_container

EXPORTING

row = 1

column = 1

RECEIVING

container = container1.

CALL METHOD splitter->get_container

EXPORTING

row = 2

column = 1

RECEIVING

container = container2.

CALL METHOD splitter->get_container

EXPORTING

row = 3

column = 1

RECEIVING

container = container3.

DATA:grid TYPE REF TO cl_gui_alv_grid.

DATA:grid1 TYPE REF TO cl_gui_alv_grid.

DATA:grid2 TYPE REF TO cl_gui_alv_grid.

DATA: o_document TYPE REF TO cl_dd_document.

CREATE OBJECT grid

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container1.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name = .

  • i_fcat_complete = space

CALL METHOD grid->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'JTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

  • is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = jtab

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

CREATE OBJECT grid1

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container2.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name =

  • i_fcat_complete = space

  • layout-grid_title = month_wa-ltx.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'KTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = ktab[]

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

CREATE OBJECT grid2

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container3.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name = .

  • i_fcat_complete = space

CALL METHOD grid2->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'LTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = ltab[]

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

*CALL METHOD grid1->set_frontend_fieldcatalog

  • EXPORTING

  • it_fieldcatalog = FCAT.

*

*CALL METHOD grid1->set_frontend_layout

  • EXPORTING

  • is_layout = LAYOUT

  • .

*

*CREATE OBJECT o_document

  • EXPORTING

  • style = 'ALV_GRID'.

    • background_color =

  • bds_stylesheet =

  • no_margins =

.

  • for adding text in top of page

*CREATE OBJECT o_document

    • EXPORTING

    • style =

    • background_color =

    • bds_stylesheet =

    • no_margins =

  • .

  • CALL METHOD o_document->add_text

  • EXPORTING

  • text = 'WA2-MONTH_NAME'

  • sap_style = cl_dd_area=>heading

  • sap_emphasis = cl_dd_area=>strong. " For bold

*

    • Display the data

  • CALL METHOD o_document->display_document

  • EXPORTING

  • parent = container1.

*

    • Calling the method of ALV to process top of page

*data:SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

*

*

*

  • CALL METHOD grid->list_processing_events

  • EXPORTING

  • i_event_name = SLIS_EV_TOP_OF_PAGE

  • i_dyndoc_id = o_document.

  • DATA: total TYPE REF TO data.

    • subtotal1 type ref to data.

*

  • FIELD-SYMBOLS <total> LIKE ktab.

**field-symbols <subtotal1> like gt_sflight.

*

  • CALL METHOD grid1->get_subtotals

  • IMPORTING

  • ep_collect00 = total.

*

*

  • ASSIGN total->* TO <total>.

*assign subtotal1-> to <subtotal1>.

ENDIF.

CALL SCREEN 2000.

&----


*& Module STATUS_2000 OUTPUT

&----


  • text

----


MODULE status_2000 OUTPUT.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE'.

ENDMODULE. " STATUS_2000 OUTPUT

&----


*& Module USER_COMMAND_2000 INPUT

&----


  • text

----


MODULE user_command_2000 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

SET SCREEN 0.

LEAVE PROGRAM.

WHEN 'EXIT'.

SET SCREEN 0.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_2000 INPUT

Thanks & Regards,

vasu

Read only

0 Kudos
1,353

H iAswath,

I have tried your logic but while activating program.it is displaying errors.

this is my program code.can you Please check this code.

&----


*& Report ZMC_PM002_GPW_OOPS1

*&

&----


*&

*&

&----


REPORT zmc_pm002_gpw_oops1.

TABLES:zmcpm_gpw_plnt,zmcpm_gpw_item.

  • SELECTION-SCREEN PARAMETERS

SELECTION-SCREEN BEGIN OF BLOCK b1

WITH FRAME TITLE text-001.

SELECT-OPTIONS:date FOR zmcpm_gpw_item-item_date.

SKIP.

PARAMETERS:plant TYPE zmcpm_gpw_plnt-werks.

SELECTION-SCREEN END OF BLOCK b1.

*FOR HOLDING CONTAINER

DATA:container TYPE REF TO cl_gui_docking_container.

data:gv_month type I.

data:gv_year(04) type c,

gv_flag type i VALUE 0,

gv_prev_month TYPE I.

*DEFINING AN INTERNAL TABLE

TYPES:BEGIN OF ty_fs,

werks TYPE werks_d,

item_no TYPE zqmnum,

item_name TYPE zmcpm_name,

item_unit TYPE meins,

item_type TYPE zmcpm_type,

item_date TYPE erdat,

item_qty TYPE zsmeng,

item_rate TYPE zkwert,

amount TYPE zmcpm_gpw_item-item_rate,

month_no type fcmnr,

month_name TYPE fcltx,

cumulativetotal TYPE zmcpm_gpw_item-item_rate,

END OF ty_fs.

DATA:wa TYPE ty_fs.

DATA:wa1 TYPE ty_fs.

DATA:wa2 TYPE ty_fs.

DATA:wa3 TYPE ty_fs.

DATA:itab TYPE STANDARD TABLE OF ty_fs.

DATA:jtab TYPE STANDARD TABLE OF ty_fs.

DATA:ktab TYPE STANDARD TABLE OF ty_fs.

DATA:ltab TYPE STANDARD TABLE OF ty_fs.

DATA:cumulativetotal TYPE p DECIMALS 2 VALUE 0.

DATA:total1 TYPE p DECIMALS 2 VALUE 0.

DATA:total2 TYPE p DECIMALS 2 VALUE 0.

DATA:total3 TYPE p DECIMALS 2 VALUE 0.

DATA:layout TYPE lvc_s_layo.

*FOR SORTING

DATA:sort_w TYPE lvc_s_sort,

sort_b TYPE lvc_t_sort.

*SPLITTING CONTAINER INTO THREE PARTS

DATA:splitter TYPE REF TO cl_gui_splitter_container.

DATA: year(4) TYPE c,

month(2) TYPE c,

day(2) TYPE c.

DATA:FCAT_WA TYPE LVC_S_FCAT.

DATA:fcat TYPE lvc_t_fcat.

DATA:month_b TYPE STANDARD TABLE OF t247,

month_wa TYPE t247.

  • TRANSFERRING DATA FROM TABLE TO INTERNAL TABLE

BREAK-POINT.

SELECT zmcpm_gpw_plnt~werks

zmcpm_gpw_item~item_no

zmcpm_gpw_item~item_name

zmcpm_gpw_item~item_unit

zmcpm_gpw_item~item_type

zmcpm_gpw_item~item_date

zmcpm_gpw_item~item_qty

zmcpm_gpw_item~item_rate

INTO TABLE itab

FROM zmcpm_gpw_item INNER JOIN zmcpm_gpw_plnt

ON zmcpm_gpw_itemitem_no = zmcpm_gpw_plntitem_no

WHERE werks = plant AND zmcpm_gpw_item~item_date BETWEEN DATE-LOW AND DATE-HIGH.

SELECT spras mnr ktx ltx FROM t247 INTO TABLE month_b WHERE spras = sy-langu.

IF NOT itab IS INITIAL.

SORT itab BY item_no item_date.

ENDIF.

**CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'

    • EXPORTING

    • i_datum_bis = date-low

    • i_datum_von = date-high

      • I_KZ_INCL_BIS = ' '

    • IMPORTING

    • e_monate = month_no.

CLEAR wa.

LOOP AT itab INTO wa.

year = wa-item_date(4).

month = wa-item_date+4(2).

day = wa-item_date+6(2).

wa-amount = wa-item_qty * wa-item_rate.

*CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH'

  • EXPORTING

  • I_DATE = wa-item_date

  • IMPORTING

  • E_MONTH = gv_month

  • E_YEAR = gv_year.

  • .

*

*

  • " for reading date

*

*

  • READ TABLE month_b INTO month_wa WITH KEY mnr = month .

*

*case gv_month.

  • when '01'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING wa to wa1.

  • APPEND wa1 to jtab.

*if not jtab is INITIAL.

  • sort jtab by item_no month_no.

  • endif.

  • when '02'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING wa to wa2.

  • APPEND wa2 to ktab.

*if not ktab is INITIAL.

  • sort ktab by item_no month_no.

  • endif.

  • when '03'.

  • wa-month_name = month_wa-ltx.

  • MOVE-CORRESPONDING WA TO WA3.

  • APPEND WA3 TO LTAB.

*if not ltab is INITIAL.

  • sort ltab by item_no month_no.

*

*endif.

  • ENDCASE.

CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year

EXPORTING

i_date = wa-item_date

IMPORTING

e_month = gv_month

e_year = gv_year.

if gv_flag ne 1.

gv_prev_month = gv_month.

gv_flag = 1.

endif.

case gv_month.

when GV_PREV_MONTH.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa1-item_no,

wa-item_name to wa1-item_name,

wa-item_unit to wa1-item_unit,

wa-item_qty to wa1-item_qty,

wa-item_rate to wa1-item_rate,

wa-amount to wa1-amount,

wa-month_name to wa1-month_name,

wa-cumulativetotal to wa1-cumulativetotal.

APPEND wa1 to jtab.

if not jtab is INITIAL.

sort jtab by item_no month_name.

endif.

when GV_PREV_MONTH + 1.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa2-item_no,

wa-item_name to wa2-item_name,

wa-item_unit to wa2-item_unit,

wa-item_qty to wa2-item_qty,

wa-item_rate to wa2-item_rate,

wa-amount to wa2-amount,

wa-month_name to wa2-month_name,

wa-cumulativetotal to wa2-cumulativetotal.

APPEND wa2 to ktab.

if not ktab is INITIAL.

sort ktab by item_no month_name.

endif.

when GV_PREV_MONTH + 2.

wa-month_name = month_wa-ltx.

MOVE: wa-item_no to wa3-item_no,

wa-item_name to wa3-item_name,

wa-item_unit to wa3-item_unit,

wa-item_qty to wa3-item_qty,

wa-item_rate to wa3-item_rate,

wa-amount to wa3-amount,

wa-month_name to wa3-month_name,

wa-cumulativetotal to wa3-cumulativetotal.

APPEND WA3 TO LTAB.

if not ltab is INITIAL.

sort ltab by item_no month_name.

endif.

endcase.

ENDLOOP.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

  • I_BUFFER_ACTIVE =

i_structure_name = 'ZMCPM_GPW_PLNT12'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_BYPASSING_BUFFER =

i_internal_tabname = 'ITAB'

CHANGING

ct_fieldcat = fcat.

sort_w-spos = 1.

sort_w-fieldname = 'ITEM_NO'.

APPEND sort_w TO sort_b .

sort_w-spos = 2.

sort_w-fieldname = 'ITEM_NAME'.

APPEND sort_w TO sort_b .

sort_w-spos = 3.

sort_w-fieldname = 'ITEM_RATE'.

APPEND sort_w TO sort_b .

sort_w-spos = 4.

sort_w-fieldname = 'ITEM_QTY'.

APPEND sort_w TO sort_b.

sort_w-spos = 5.

sort_w-fieldname = 'AMOUNT'.

*SORT_W-SUBTOT = 'X'.

APPEND sort_w TO sort_b.

sort_w-spos = 6.

sort_w-fieldname = 'CUMULATIVETOTAL'.

APPEND sort_w TO sort_b.

sort_w-spos = 7.

sort_w-fieldname = 'MONTH_NAME' .

APPEND sort_w TO sort_b.

IF container IS INITIAL.

CREATE OBJECT container

EXPORTING

  • parent =

repid = sy-repid

dynnr = '2000'

side = container->dock_at_top

extension = 1000

  • style =

  • lifetime = lifetime_default

  • caption =

  • metric = 0

  • ratio =

  • no_autodef_progid_dynnr =

name = 'QUARTERLY REPORT' .

CREATE OBJECT splitter

EXPORTING

  • link_dynnr =

  • link_repid =

  • shellstyle =

  • left =

  • top =

  • width =

  • height =

  • metric = cntl_metric_dynpro

  • align = 15

parent = container

rows = 3

columns = 1.

  • no_autodef_progid_dynnr =

  • name =

DATA:container1 TYPE REF TO cl_gui_container.

DATA:container2 TYPE REF TO cl_gui_container.

DATA:container3 TYPE REF TO cl_gui_container.

DATA:container4 TYPE REF TO cl_gui_container.

CALL METHOD splitter->get_container

EXPORTING

row = 1

column = 1

RECEIVING

container = container1.

CALL METHOD splitter->get_container

EXPORTING

row = 2

column = 1

RECEIVING

container = container2.

CALL METHOD splitter->get_container

EXPORTING

row = 3

column = 1

RECEIVING

container = container3.

DATA:grid TYPE REF TO cl_gui_alv_grid.

DATA:grid1 TYPE REF TO cl_gui_alv_grid.

DATA:grid2 TYPE REF TO cl_gui_alv_grid.

DATA: o_document TYPE REF TO cl_dd_document.

CREATE OBJECT grid

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container1.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name = .

  • i_fcat_complete = space

CALL METHOD grid->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'JTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

  • is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = jtab

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

CREATE OBJECT grid1

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container2.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name =

  • i_fcat_complete = space

  • layout-grid_title = month_wa-ltx.

CALL METHOD grid1->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'KTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = ktab[]

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

CREATE OBJECT grid2

EXPORTING

  • i_shellstyle = 0

  • i_lifetime =

i_parent = container3.

  • i_appl_events = space

  • i_parentdbg =

  • i_applogparent =

  • i_graphicsparent =

  • i_name = .

  • i_fcat_complete = space

CALL METHOD grid2->set_table_for_first_display

EXPORTING

  • i_buffer_active =

  • i_bypassing_buffer =

  • i_consistency_check =

i_structure_name = 'LTAB'

  • is_variant =

  • i_save =

  • i_default = 'X'

is_layout = layout

  • is_print =

  • it_special_groups =

  • it_toolbar_excluding =

  • it_hyperlink =

  • it_alv_graphics =

  • it_except_qinfo =

  • ir_salv_adapter =

CHANGING

it_outtab = ltab[]

it_fieldcatalog = fcat

it_sort = sort_b.

  • it_filter =

*CALL METHOD grid1->set_frontend_fieldcatalog

  • EXPORTING

  • it_fieldcatalog = FCAT.

*

*CALL METHOD grid1->set_frontend_layout

  • EXPORTING

  • is_layout = LAYOUT

  • .

*

*CREATE OBJECT o_document

  • EXPORTING

  • style = 'ALV_GRID'.

    • background_color =

  • bds_stylesheet =

  • no_margins =

.

  • for adding text in top of page

*CREATE OBJECT o_document

    • EXPORTING

    • style =

    • background_color =

    • bds_stylesheet =

    • no_margins =

  • .

  • CALL METHOD o_document->add_text

  • EXPORTING

  • text = 'WA2-MONTH_NAME'

  • sap_style = cl_dd_area=>heading

  • sap_emphasis = cl_dd_area=>strong. " For bold

*

    • Display the data

  • CALL METHOD o_document->display_document

  • EXPORTING

  • parent = container1.

*

    • Calling the method of ALV to process top of page

*data:SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

*

*

*

  • CALL METHOD grid->list_processing_events

  • EXPORTING

  • i_event_name = SLIS_EV_TOP_OF_PAGE

  • i_dyndoc_id = o_document.

  • DATA: total TYPE REF TO data.

    • subtotal1 type ref to data.

*

  • FIELD-SYMBOLS <total> LIKE ktab.

**field-symbols <subtotal1> like gt_sflight.

*

  • CALL METHOD grid1->get_subtotals

  • IMPORTING

  • ep_collect00 = total.

*

*

  • ASSIGN total->* TO <total>.

*assign subtotal1-> to <subtotal1>.

ENDIF.

CALL SCREEN 2000.

&----


*& Module STATUS_2000 OUTPUT

&----


  • text

----


MODULE status_2000 OUTPUT.

SET PF-STATUS 'ZSTATUS'.

SET TITLEBAR 'ZTITLE'.

ENDMODULE. " STATUS_2000 OUTPUT

&----


*& Module USER_COMMAND_2000 INPUT

&----


  • text

----


MODULE user_command_2000 INPUT.

CASE sy-ucomm.

WHEN 'BACK'.

SET SCREEN 0.

LEAVE PROGRAM.

WHEN 'EXIT'.

SET SCREEN 0.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_2000 INPUT

Thanks & Regards,

vasu

Read only

0 Kudos
1,353

Hi,

try this i dont think you will get error this time.


data: gv_month type am_monat,
      gv_prev_month1 TYPE am_monat,
      gv_prev_month2 type am_monat,
      gv_prev_month type am_monat.

CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year
EXPORTING i_date = wa-item_date
   IMPORTING e_month = gv_month
      e_year = gv_year.
IF gv_flag NE 1.
  gv_prev_month = gv_month.
  gv_flag = 1.
ENDIF.
gv_prev_month1 = gv_prev_month + 1.
gv_prev_month2 = gv_prev_month + 1.

CASE gv_month.
  WHEN gv_prev_month.
    wa-month_name = month_wa-ltx.
    MOVE: wa-item_no TO wa1-item_no,
    wa-item_name TO wa1-item_name,
    wa-item_unit TO wa1-item_unit,
     wa-item_qty TO wa1-item_qty,
      wa-item_rate TO wa1-item_rate,
wa-amount TO wa1-amount,
wa-month_name TO wa1-month_name,
wa-cumulativetotal TO wa1-cumulativetotal.
    APPEND wa1 TO jtab.
    IF NOT jtab IS INITIAL.
      SORT jtab BY item_no month_name.
    ENDIF.
  WHEN gv_prev_month1.
    wa-month_name = month_wa-ltx.
    MOVE: wa-item_no TO wa2-item_no,
     wa-item_name TO wa2-item_name,
      wa-item_unit TO wa2-item_unit,
      wa-item_qty TO wa2-item_qty,
      wa-item_rate TO wa2-item_rate,
      wa-amount TO wa2-amount,
      wa-month_name TO wa2-month_name,
       wa-cumulativetotal TO wa2-cumulativetotal.
    APPEND wa2 TO ktab.
    IF NOT ktab IS INITIAL.
      SORT ktab BY item_no month_name.
    ENDIF.
  WHEN gv_prev_month2.
    wa-month_name = month_wa-ltx.
    MOVE: wa-item_no TO wa3-item_no,
     wa-item_name TO wa3-item_name,
      wa-item_unit TO wa3-item_unit,
       wa-item_qty TO wa3-item_qty,
       wa-item_rate TO wa3-item_rate,
        wa-amount TO wa3-amount,
        wa-month_name TO wa3-month_name,
        wa-cumulativetotal TO wa3-cumulativetotal.
    APPEND wa3 TO ltab.
    IF NOT ltab IS INITIAL.
      SORT ltab BY item_no month_name.
    ENDIF.
ENDCASE.

thanks and regards.

Aswath.

Read only

0 Kudos
1,353

Hi Aswanth,

I have tried your logic.it is working but total data is moving to first internal table.data didn't split based date range.

and more thing i have to display below format in grid control.Is it possible means .please tell me.

GAS PRESSURE WELDING COST EFFECTIVENESS Dec-11 Cummulativetotal

Sr. No Item Unit Rate Qty Amount

GAS PRESSURE WELDING COST EFFECTIVENESS Jan-12

Sr. No Item Unit Rate Qty Amount

GAS PRESSURE WELDING COST EFFECTIVENESS Feb-12

Sr. No Item Unit Rate Qty Amount

Thanks & Regards,

Vasu.

Read only

0 Kudos
1,353

Hi,

You should use this logic looping through your internal table where you have all the data with the corresponding date. Since you are using it outside only for one date the date is coming i suppose. Try looping your main internal table and based on the above logic pass the date to different internal table.

And for your display requirment you have to have 3 different containers with 3 top-of-page events where you can display the text you mentioned. It is simple since you have data in 3 different internal tables.

1> Create 3 different containers.

2> For each container use top-of-page event to include the text.

3> Pass the 3 different internal tables to the corresponding containers.

Its looks complicated but simple only because whatever you do for one container applies for the second and third also with only one difference is the internal table that you pass.

Thanks and regards.

Aswath.

Read only

0 Kudos
1,353

I WANT THE OUTPUT AS:

TOP - GAS PRESSURE WELDING MONTH

HEADER FIELDS - Sr. No Item Unit Rate Qty Amount Qty

1 20 50 1000 20

2

Read only

0 Kudos
1,353

Hi,

Are you getting the data into 3 different tables now?

If so Use three different containers with top of page event for each. In top of page event you can display tha First line right, And for header fields you will have fieldcatalog and for data internal table.

Please revert in case of issue with how you r trying to display.

Thanks and regards.

Aswath.

Read only

0 Kudos
1,353

Dear Vasuabap ,

Just a suggestion.Instead of splitting the ALV, why don't you use a single Alv grid.

Add a column "Months" and take a subtotal on this column using standard ALV functionality.

Create a default variant and save it so that your report output will always be displayed with Subtotal by "Months" column.

Regards,

Rijuraj

Read only

0 Kudos
1,353

Hi Aswanth,

i have tried as per your logic but total amount of data is moving to first internal table.that is the problem.when i hard coded like

case gv_month .

when 1.

move-corresponding wa to jtab.

when 2.

move-corresponding wa to ktab.

when 3.

move-corresponding wa to ltab.

in that time only data can be moving to respected internal tables . but i need display month wise data means some times i will give date range Jan from to march.i some times i will give date range from Oct to DEC. means date range will different in some times

Please guide me Aswanth.

Awaiting for your reply,

Thanks & Regards,

Vasu.

Read only

0 Kudos
1,353

Hi,


DATA: gv_month TYPE am_monat,
      gv_prev_month1 TYPE am_monat,
      gv_prev_month2 TYPE am_monat,
      gv_prev_month TYPE am_monat.

DATA: gv_flag TYPE i.
data: date type sy-datum.
date = sy-datum.

do 3 times.  " Loop your main table into work area where date is there to split to 3 different internal table
add 25 to date.
CALL FUNCTION 'CACS_DATE_GET_YEAR_MONTH' "get the month and year
EXPORTING
  i_date = date
   IMPORTING
     e_month = gv_month.
IF gv_flag NE 1.
  gv_prev_month = gv_month.
  gv_flag = 1.
ENDIF.
gv_prev_month1 = gv_prev_month + 1.
gv_prev_month2 = gv_prev_month + 2.

CASE gv_month.
  WHEN gv_prev_month.
    WRITE:/ 'first'.
  WHEN gv_prev_month1.
    WRITE:/ 'second'.
  WHEN gv_prev_month2.
    WRITE:/ 'third'.
ENDCASE.
ENDDO.

Hi this is just an example i tried just to check whether case statement is working or not and it is working fine. Just loop through your Main internal table which has the dates of 3 months into a work area and provide this workarea date to the function module i specified. This should definitely work. Otherwise post the code of this logic please.

Thanks and regards.

Aswath.