Skip to Content

grahical reports in abap how to devlop

hi all

can u please tell me how to display reports in graphical form 2d or 3d using abap programming

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 09:30 AM

    hi,

    check this standard Program GRAPHICS_GUI_CE_DEMO

    Thanks

    Murugan.B

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 17, 2008 at 09:41 AM

    hi deepika,

    check the transaction GRAL .u will get list of programs related to sap graphics.

    also check this sample program, just copy paste in se38 and execute.

    &----


    *& Report ZGM_ALV_GRAPH *

    *& *

    &----


    *& *

    *& *

    &----


    REPORT ZGM_ALV_GRAPH .

    *structure declaration for performance measurement

    TYPES: BEGIN OF ty_performance,

    COMPANY(15) TYPE C,

    Q1 TYPE I,

    Q2 TYPE I,

    Q3 TYPE I,

    Q4 TYPE I,

    END OF TY_PERFORMANCE.

    *STRUCTURE DECLARATION FOR OPTIONS TABLE

    TYPES : BEGIN OF TY_OPTTABLE,

    OPTIONS(30) TYPE C,

    END OF TY_OPTTABLE.

    *INTERNAL TABLE AND WORK AREA DECLARATIONS

    DATA : IT_PERFORMANCE TYPE STANDARD TABLE OF TY_PERFORMANCE,

    WA_PERFORMANCE TYPE TY_PERFORMANCE.

    DATA : IT_OPTTABLE TYPE STANDARD TABLE OF TY_OPTTABLE,

    WA_OPTTABLE TYPE TY_OPTTABLE.

    *INITIALIZATION EVENT

    INITIALIZATION.

    *START OF SELECTION EVENT

    START-OF-SELECTION.

    *CLEARING THE WORK AREAS

    CLEAR WA_PERFORMANCE.

    CLEAR WA_OPTTABLE.

    *APPENDING VALUES INTO THE PERFORMANCE INTERNAL TABLE

    WA_PERFORMANCE-COMPANY = 'Company A'.

    WA_PERFORMANCE-Q1 = 78.

    WA_PERFORMANCE-Q2 = 68.

    WA_PERFORMANCE-Q3 = 79.

    WA_PERFORMANCE-Q4 = 80.

    APPEND WA_PERFORMANCE TO IT_PERFORMANCE.

    WA_PERFORMANCE-COMPANY = 'Company B'.

    WA_PERFORMANCE-Q1 = 48.

    WA_PERFORMANCE-Q2 = 68.

    WA_PERFORMANCE-Q3 = 69.

    WA_PERFORMANCE-Q4 = 70.

    APPEND WA_PERFORMANCE TO IT_PERFORMANCE.

    WA_PERFORMANCE-COMPANY = 'Company C'.

    WA_PERFORMANCE-Q1 = 78.

    WA_PERFORMANCE-Q2 = 48.

    WA_PERFORMANCE-Q3 = 79.

    WA_PERFORMANCE-Q4 = 85.

    APPEND WA_PERFORMANCE TO IT_PERFORMANCE.

    *APPENDING VALUES INTO THE OPTIONS INTERNAL TABLE

    WA_OPTTABLE-OPTIONS = 'P3TYPE = TO'.

    APPEND WA_OPTTABLE TO IT_OPTTABLE.

    WA_OPTTABLE-OPTIONS = 'P2TYPE = VB'.

    APPEND WA_OPTTABLE TO IT_OPTTABLE.

    WA_OPTTABLE-OPTIONS = 'TISIZE = 1'.

    APPEND WA_OPTTABLE TO IT_OPTTABLE.

    *CALLING THE GRAPH FUNCTION MODULE

    CALL FUNCTION 'GRAPH_MATRIX_3D'

    EXPORTING

    COL1 = 'Quarter 1'

    COL2 = 'Quarter 2'

    COL3 = 'Quarter 3'

    COL4 = 'Quarter 4'

    DIM1 = 'In Percentage%'

    SET_FOCUS = 'X'

    TITL = 'Company Performances'

    TABLES

    DATA = IT_PERFORMANCE

    OPTS = IT_OPTTABLE

    EXCEPTIONS

    OTHERS = 1.

    reward points if hlpful.

    regards,

    gautham.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 11:48 AM

    Hi Deepika jain,

    Go to the transaction GRAL where you can find a list of demo programs to print the output in graphical form.

    Reward if useful.

    Thanks,

    Surya

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 03:06 PM

    Hi ,

    Paste this code in se38,

    PERFORM create_chart is important for you.

    &----


    *& Report ZMM_INV_TURNS_REPORT *

    *& *

    *& Author Vijay Babu Dudla *

    *& Date 25th April 2008 *

    &----


    • Description : Inventory Turns Report *

    • *

    • *

    _____________________________________________________________________

    • Inputs: *

    • Tables: *

    • ECMT - COGS data *

    • GLTO - Inventory Data *

    • *

    • Parameters: *

    • From Period *

    • Year *

    • To Period *

    • Year *

    • Company Code

    • Parameters: *

    • N/A *

    • Outputs: A ALV report is generated to display the Inventory Turns *

    _____________________________________________________________________

    • External Routines *

    • Classes: CL_GUI_ALV_GRID *

    • CL_IGS_CHART *

    • Transactions : No *

    • Programs : No *

    _____________________________________________________________________

    • Return Codes: No *

    _____________________________________________________________________

    • Ammendments: *

    • Programmer Date Req. # Action *

    • ================ ========== ====== ==============================*

    • Vijay Dudla 04/15/2008 RD4K900255 Initial Development *

    • RMANDAL 05/18/2008 RD4K900419 1) Getting COGS values *

    • from ZSCOMMON *

    • 2) Displying values in *

    • Graph *

    ***********************************************************************

    REPORT zmm_inv_turns_report MESSAGE-ID zi.

    *-TYPES Declaration

    *- Period Details

    TYPES: BEGIN OF ty_period,

    perid TYPE fc_perid, " Period

    END OF ty_period.

    *-Year Details

    TYPES: BEGIN OF ty_year,

    gjahr TYPE gjahr, " Year

    END OF ty_year.

    *-Final Display Table

    TYPES: BEGIN OF ty_data,

    texts(20), " Col Value

    per01(20), " Period1

    per02(20), " Period2

    per03(20), " Period3

    per04(20), " Period4

    per05(20), " Period5

    per06(20), " Period6

    per07(20), " Period7

    per08(20), " Period8

    per09(20), " Period9

    per10(20), " Period10

    per11(20), " Period11

    per12(20), " Period12

    year TYPE gjahr,

    END OF ty_data.

    *-Period Balance information

    TYPES: BEGIN OF ty_balance,

    period TYPE fc_perid, " Period

    gjahr TYPE gjahr, " Year

    tslvt TYPE tslxx, " Balance

    END OF ty_balance.

    *- Period and Year info

    TYPES: BEGIN OF ty_per_year,

    period TYPE fc_perid, " Period

    gjahr TYPE gjahr, " Year

    END OF ty_per_year.

    *- Field Symbols

    FIELD-SYMBOLS: <fs> TYPE ANY.

    *- Data Declarations

    *- Internal Table Decleations

    DATA: it_fieldcat TYPE lvc_t_fcat, " Fieldcatalog

    it_per TYPE STANDARD TABLE OF zmm_year_period,

    it_year_per TYPE zmm_t_inv_period,

    it_final TYPE STANDARD TABLE OF ty_data,

    it_year TYPE STANDARD TABLE OF ty_year,

    it_period TYPE STANDARD TABLE OF ty_period,

    it_common TYPE STANDARD TABLE OF zscommon,

    • BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419

    it_common1 TYPE STANDARD TABLE OF zscommon,

    • END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419

    it_inv TYPE STANDARD TABLE OF glt0,

    it_cogs TYPE STANDARD TABLE OF ecmct,

    • it_inv_data TYPE STANDARD TABLE OF zfi_year_period,

    it_balance TYPE STANDARD TABLE OF ty_balance,

    it_peryear TYPE STANDARD TABLE OF ty_per_year

    WITH HEADER LINE.

    *- Work Area declarations

    DATA: wa_fieldcat TYPE lvc_s_fcat,

    w_per TYPE zmm_year_period,

    w_period TYPE zmm_inv_period,

    wa_final TYPE ty_data,

    • wa_inv TYPE zfi_year_period,

    wa_per TYPE ty_period,

    wa_balance TYPE ty_balance.

    *- Range table Declations

    DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE,

    r_year TYPE RANGE OF gjahr WITH HEADER LINE,

    r_yr TYPE RANGE OF gjahr WITH HEADER LINE,

    r_per TYPE RANGE OF fc_perid WITH HEADER LINE,

    r_saknr TYPE RANGE OF racct.

    *- Variable to Period and Year

    DATA: perid TYPE fc_perid,

    year TYPE gjahr,

    w_bukrs TYPE glt0-bukrs.

    *- Graph Display

    DATA: g_html TYPE w3htmltabtype,

    g_url TYPE w3url.

    *-Controls for Displaying the Grpah and ALV Report

    DATA: grid TYPE REF TO cl_gui_alv_grid,

    split TYPE REF TO cl_gui_splitter_container,

    cont TYPE REF TO cl_gui_custom_container,

    gridcon TYPE REF TO cl_gui_container,

    htmlcon TYPE REF TO cl_gui_container,

    html_control TYPE REF TO cl_gui_html_viewer.

    &----


    *& Selection Screen *

    &----


    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-ttl.

    SELECT-OPTIONS: s_per FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,

    • " Period

    s_year FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.

    • " Year

    SELECTION-SCREEN END OF BLOCK b1.

    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-tt2.

    SELECT-OPTIONS: s_per2 FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,

    • " Period

    s_year2 FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.

    • " Year

    SELECTION-SCREEN END OF BLOCK b2.

    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-tt3 .

    PARAMETERS: p_rep RADIOBUTTON GROUP g1 DEFAULT 'X',

    p_grp RADIOBUTTON GROUP g1,

    p_bot RADIOBUTTON GROUP g1.

    SELECTION-SCREEN END OF BLOCK b3.

    PARAMETERS: p_bukrs LIKE glt0-bukrs DEFAULT '3000' OBLIGATORY.

    &----


    *& AT SELECTION-SCREEN ON VALUE REQUEST *

    &----


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_year-low.

    *-Value help for year

    PERFORM get_hlp_for_year.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_per-low.

    *-Value help for Period

    PERFORM get_hlp_for_period.

    &----


    *& AT SELECTION-SCREEN *

    &----


    AT SELECTION-SCREEN .

    *-Validations

    *- Per Period should be 1 to 12

    LOOP AT s_per.

    IF s_per-low GT 12 OR s_per-low LT 1.

    MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.

    ENDIF. " IF s_per-low GT 12 OR s_per-low

    IF NOT s_per-high IS INITIAL.

    IF s_per-high GT 12 OR s_per-high LT 1.

    MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.

    ENDIF. " IF s_per-high GT 12 OR

    ENDIF. " IF NOT s_per-high IS INITIAL

    ENDLOOP. " LOOP AT s_per

    IF s_per-low GE sy-datum+4(2) AND

    s_year-low GE sy-datum+0(4).

    MESSAGE e000(zi) WITH text-002 text-003.

    ENDIF. " IF s_per-low GE sy-datum+4(2)

    LOOP AT s_per2.

    IF s_per2-low GT 12 OR s_per2-low LT 1.

    MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.

    ENDIF. " IF s_per2-low GT 12 OR

    ENDLOOP. " LOOP AT s_per2.

    IF s_per2-low GE sy-datum+4(2) AND

    s_year2-low GE sy-datum+0(4).

    MESSAGE e000(zi) WITH text-002 text-003.

    ENDIF. " IF s_per2-low GE sy-datum+4(2)

    • Company Code Validation

    IF p_bukrs IS NOT INITIAL.

    SELECT

    SINGLE bukrs " Company Code

    FROM t001

    INTO w_bukrs

    WHERE bukrs = p_bukrs.

    IF sy-subrc NE 0.

    MESSAGE e000(zi) WITH 'Enter Valid Company code '.

    ENDIF. " IF sy-subrc NE 0.

    CLEAR w_bukrs.

    ENDIF. " IF p_bukrs IS NOT

    &----


    *& START OF SELECTION *

    &----


    START-OF-SELECTION.

    *-Get the GL Accounts from table ZSCOMMON

    PERFORM get_gl_information.

    *-Get the Inventory Details

    PERFORM get_inventory_data.

    *-Get the COGS details

    PERFORM get_cogs_data.

    *-Population of Period Table

    PERFORM populate_period_data.

    *-Populate the Final Data

    PERFORM populate_final_data.

    &----


    *& END OF SELECTION *

    &----


    END-OF-SELECTION.

    *-Display the Output

    PERFORM display_inv_turn_data.

    &----


    *& Form get_hlp_for_year

    &----


    • Get the Value help for Year

    ----


    FORM get_hlp_for_year.

    *-Populate the F4 Values for Year

    SELECT pabrj

    FROM t549q

    INTO

    TABLE it_year.

    IF sy-subrc EQ 0.

    SORT it_year.

    DELETE it_year WHERE gjahr = ''.

    DELETE ADJACENT DUPLICATES FROM it_year

    COMPARING gjahr.

    *-Attaching the F4 Help to The Selection parameter

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'GJAHR'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    value_org = 'S'

    TABLES

    value_tab = it_year

    return_tab = return

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    IF sy-subrc EQ 0.

    READ TABLE return INDEX 1.

    s_year-low = return-fieldval.

    ENDIF. " IF sy-subrc EQ 0

    ENDIF. " IF sy-subrc EQ 0

    ENDFORM. " get_hlp_for_year

    &----


    *& Form get_hlp_for_period

    &----


    • Get the Search help for Period

    ----


    FORM get_hlp_for_period.

    *-Population of Period to Display the F4 values

    CLEAR return[].

    wa_per-perid = '001'.

    DO 12 TIMES.

    APPEND wa_per TO it_period.

    wa_per-perid = wa_per-perid + 1.

    ENDDO. " DO 12 TIMES.

    *-Attaching the F4 values to the selection parameter

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

    EXPORTING

    retfield = 'PERID'

    dynpprog = sy-repid

    dynpnr = sy-dynnr

    value_org = 'S'

    TABLES

    value_tab = it_period

    return_tab = return

    EXCEPTIONS

    parameter_error = 1

    no_values_found = 2

    OTHERS = 3.

    IF sy-subrc EQ 0.

    READ TABLE return INDEX 1.

    s_per-low = return-fieldval.

    ENDIF. " IF sy-subrc EQ 0

    ENDFORM. " get_hlp_for_period

    &----


    *& Form GET_GL_INFORMATION

    &----


    • Get the GL account Information from ZSCOMMON table

    ----


    FORM get_gl_information .

    DATA: wa_common TYPE zscommon,

    wa_saknr LIKE LINE OF r_saknr.

    *-GL Accounts from ZSCOMMON

    SELECT *

    FROM zscommon

    INTO

    TABLE it_common

    WHERE programm = sy-repid AND

    code = 'GLAC'.

    IF sy-subrc EQ 0.

    wa_saknr-sign = 'I'.

    wa_saknr-option = 'EQ'.

    LOOP AT it_common INTO wa_common.

    wa_saknr-low = wa_common-valuestrng.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    input = wa_saknr-low

    IMPORTING

    output = wa_saknr-low.

    APPEND wa_saknr TO r_saknr.

    ENDLOOP. " LOOP AT it_common

    ENDIF. " IF sy-subrc EQ 0

    ENDFORM. " GET_GL_INFORMATION

    &----


    *& Form GET_INVENTORY_DATA

    &----


    • Get the Inventory Data

    ----


    FORM get_inventory_data .

    REFRESH r_year.

    r_year-sign = 'I'.

    r_year-option = 'EQ'.

    *-Populate the Year from Selection Parameters

    LOOP AT s_year.

    r_year-low = s_year-low.

    APPEND r_year.

    r_year-low = r_year-low - 1.

    APPEND r_year.

    r_year-low = s_year-low.

    IF s_year2-low IS NOT INITIAL.

    DO.

    r_year-low = r_year-low + 1.

    IF r_year-low GT s_year2-low.

    EXIT.

    ENDIF. " IF r_year-low GT

    APPEND r_year.

    ENDDO. " DO

    ENDIF. " IF s_year2-low IS NOT

    ENDLOOP. " LOOP AT s_year

    CLEAR r_year.

    SORT r_year BY low.

    DELETE ADJACENT DUPLICATES FROM r_year COMPARING low.

    r_yr-sign = 'I'.

    r_yr-option = 'EQ'.

    LOOP AT s_year.

    r_yr-low = s_year-low.

    APPEND r_yr.

    IF s_year2-low IS NOT INITIAL.

    DO.

    r_yr-low = r_yr-low + 1.

    IF r_yr-low GT s_year2-low.

    EXIT.

    ENDIF. " IF r_yr-low GT s_year2-low

    APPEND r_yr.

    ENDDO. " DO

    ENDIF. " IF s_year2-low IS NOT

    ENDLOOP. " LOOP AT s_year

    *-Get the Inventory Data

    SELECT *

    FROM glt0

    INTO TABLE it_inv

    WHERE bukrs = p_bukrs AND

    ryear IN r_year AND

    racct IN r_saknr.

    ENDFORM. " GET_INVENTORY_DATA

    &----


    *& Form GET_COGS_DATA

    &----


    • Get the COGS data

    ----


    FORM get_cogs_data .

    DATA: s_item TYPE RANGE OF fc_item,

    wa_item LIKE LINE OF s_item.

    • BEGIN OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419

    data: wa_common1 TYPE zscommon.

    SELECT *

    FROM zscommon

    INTO

    TABLE it_common1

    WHERE programm = sy-repid AND

    code = 'CCOA'.

    IF sy-subrc EQ 0.

    wa_item-sign = 'I'.

    wa_item-option = 'EQ'.

    LOOP AT it_common1 INTO wa_common1.

    wa_item-low = wa_common1-valuestrng.

    APPEND wa_item TO s_item.

    ENDLOOP. " LOOP AT it_common1

    ENDIF. " IF sy-subrc EQ 0

    *

    • wa_item-sign = 'I'.

    • wa_item-option = 'EQ'.

    • wa_item-low = '0000005000'.

    • APPEND wa_item TO s_item.

    • wa_item-low = '0000006100'.

    • APPEND wa_item TO s_item.

    • wa_item-low = '0000007900'.

    • APPEND wa_item TO s_item.

    • END OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419

    *-Population of COGS information

    SELECT *

    FROM ecmct

    INTO TABLE it_cogs

    WHERE ryear IN r_year AND

    rbunit EQ '000000000000003000' AND

    ritem IN s_item AND

    ( ( sityp EQ '2 ' AND

    subit EQ '0100 ')

    OR

    ( sityp EQ ' ' AND

    subit EQ ' ') ).

    IF sy-subrc EQ 0.

    ENDIF. " IF sy-subrc EQ 0

    ENDFORM. " GET_COGS_DATA

    &----


    *& Form POPULATE_FINAL_DATA

    &----


    • Population of final Data

    ----


    FORM populate_final_data .

    DATA: inc(2) TYPE n,

    w_pert(15),

    col(5).

    *Field catalog population.

    wa_fieldcat-fieldname = 'TEXTS'.

    wa_fieldcat-outputlen = 20.

    wa_fieldcat-coltext = 'Info'.

    APPEND wa_fieldcat TO it_fieldcat.

    inc = 1.

    DO 12 TIMES.

    CONCATENATE 'PER' inc INTO wa_fieldcat-fieldname.

    CONCATENATE 'PER' inc INTO wa_fieldcat-coltext.

    wa_fieldcat-outputlen = 20.

    wa_fieldcat-just = 'R'.

    APPEND wa_fieldcat TO it_fieldcat.

    CLEAR wa_fieldcat .

    inc = inc + 1.

    ENDDO. " DO 12 TIMES.

    SORT it_per BY year period.

    inc = 1.

    *-Final Internal table formation

    LOOP AT it_per INTO w_per.

    READ TABLE it_final WITH KEY year = w_per-year

    TRANSPORTING NO FIELDS.

    IF sy-subrc NE 0.

    wa_final-texts = w_per-year.

    wa_final-year = w_per-year.

    inc = 1.

    DO 12 TIMES.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    ASSIGN (w_pert) TO <fs>.

    <fs> = inc.

    inc = inc + 1.

    ENDDO. " DO 12 TIMES

    APPEND wa_final TO it_final.

    CLEAR wa_final.

    inc = w_per-period+1(2).

    wa_final-year = w_per-year.

    wa_final-texts = 'COGS Tot(12 months)'.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-cogs.

    APPEND wa_final TO it_final.

    wa_final-texts = 'Inv Total(12 months)'.

    wa_final-year = w_per-year.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invtot.

    APPEND wa_final TO it_final.

    wa_final-texts = 'Inv Avg(monthly)'.

    wa_final-year = w_per-year.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invavg.

    APPEND wa_final TO it_final.

    wa_final-texts = 'Turns(COGS/Inv.Avg)'.

    wa_final-year = w_per-year.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invturn.

    APPEND wa_final TO it_final.

    CLEAR wa_final.

    APPEND wa_final TO it_final.

    ELSE.

    inc = w_per-period+1(2).

    • wa_final-texts = 'COGS Total(12 months)'.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    CONCATENATE 'PER' inc INTO col.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-cogs.

    MODIFY it_final FROM wa_final TRANSPORTING (col)

    WHERE texts = 'COGS Tot(12 months)'

    AND year = w_per-year.

    wa_final-texts = 'Inv Total(12 months)'.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    CONCATENATE 'PER' inc INTO col.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invtot.

    MODIFY it_final FROM wa_final TRANSPORTING (col)

    WHERE texts = 'Inv Total(12 months)'

    AND year = w_per-year .

    wa_final-texts = 'Inv Avg(monthly)'.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    CONCATENATE 'PER' inc INTO col.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invavg.

    MODIFY it_final FROM wa_final TRANSPORTING (col)

    WHERE texts = 'Inv Avg(monthly)'

    AND year = w_per-year

    .

    wa_final-texts = 'Turns(COGS/Inv.Avg)'.

    CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.

    CONCATENATE 'PER' inc INTO col.

    ASSIGN (w_pert) TO <fs>.

    <fs> = w_per-invturn.

    MODIFY it_final FROM wa_final TRANSPORTING (col)

    WHERE texts = 'Turns(COGS/Inv.Avg)'

    AND year = w_per-year .

    CLEAR wa_final.

    ENDIF. " IF sy-subrc NE 0

    ENDLOOP. " LOOP AT it_per INTO

    ENDFORM. " POPULATE_FINAL_DATA

    *&----


    *& Form DISPLAY_INV_TURN_DATA

    &----


    • Display Inventory Turns Report

    ----


    FORM display_inv_turn_data .

    IF NOT it_final IS INITIAL.

    *-Save the Data

    • PERFORM save_data.

    CALL SCREEN 100.

    ELSE.

    MESSAGE s000(zi) WITH 'No data for selection'.

    ENDIF. " IF NOT it_final

    ENDFORM. " DISPLAY_INV_TURN_DATA

    &----


    *& Form POPULATE_PERIOD_DATA

    &----


    • Populate the Period Data

    ----


    FORM populate_period_data .

    *- Work Variables

    DATA: wa_inv TYPE glt0,

    wa_cog TYPE ecmct,

    w_amt(12),

    w_debit TYPE tslxx,

    w_credit TYPE tslxx,

    w_invtot TYPE tslxx,

    w_cogstot TYPE tslxx,

    w_bal1 TYPE tslxx,

    w_bal2 TYPE tslxx,

    w_total TYPE tslxx,

    w_inc(2) TYPE n,

    w_perd TYPE fc_perid,

    w_bal(12),

    lv_period TYPE fc_perid,

    lv_year TYPE gjahr,

    w_change.

    *- Field Symbols

    FIELD-SYMBOLS: <fs> TYPE ANY,

    <fs_bal> TYPE ANY.

    *-Population of Balance for all Periods.

    SORT it_inv BY ryear.

    LOOP AT r_year.

    CLEAR: w_debit,w_credit,

    w_bal1,w_bal2,w_total.

    wa_balance-gjahr = r_year-low.

    LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND

    drcrk = 'S' .

    w_bal1 = w_bal1 + wa_inv-tslvt.

    CLEAR wa_inv-tslvt.

    ENDLOOP. " LOOP AT it_inv

    LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND

    drcrk = 'H' .

    wa_inv-tslvt = wa_inv-tslvt * -1.

    w_bal2 = w_bal2 + wa_inv-tslvt.

    CLEAR wa_inv-tslvt.

    ENDLOOP. " LOOP AT it_inv INTO wa_inv

    w_total = w_bal1 - w_bal2.

    w_inc = 1.

    DO 12 TIMES.

    LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND

    drcrk = 'S' .

    CLEAR: w_bal.

    CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.

    ASSIGN (w_bal) TO <fs_bal>.

    w_debit = w_debit + <fs_bal>.

    UNASSIGN <fs_bal>.

    ENDLOOP. " LOOP AT it_inv INTO wa_inv

    LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND

    drcrk = 'H' .

    CLEAR: w_bal.

    CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.

    ASSIGN (w_bal) TO <fs_bal>.

    <fs_bal> = <fs_bal> * -1.

    w_credit = w_credit + <fs_bal>.

    UNASSIGN <fs_bal>.

    ENDLOOP. " LOOP AT it_inv INTO wa_inv

    wa_balance-tslvt = w_debit - w_credit + w_total.

    wa_balance-period = w_inc.

    APPEND wa_balance TO it_balance.

    w_inc = w_inc + 1.

    ENDDO. " DO 12 TIMES

    ENDLOOP. " LOOP AT r_year

    CLEAR: w_credit,w_debit.

    r_per-sign = 'I'.

    r_per-option = 'EQ'.

    CLEAR it_peryear[].

    *-Populate the periods

    r_per-low = s_per-low.

    lv_year = s_year-low.

    DO .

    it_peryear-period = r_per-low.

    it_peryear-gjahr = lv_year.

    APPEND it_peryear.

    IF r_per-low GE s_per2-low AND

    lv_year EQ s_year2-low.

    EXIT.

    ENDIF. " IF r_per-low GE s_per2

    IF r_per-low = 12.

    r_per-low = 1.

    lv_year = lv_year + 1.

    ELSE.

    r_per-low = r_per-low + 1.

    ENDIF. " IF r_per-low = 12

    ENDDO. " DO

    CLEAR: r_per,r_year,w_change.

    *-Population of the Turns information based on Period and year

    LOOP AT it_peryear.

    w_perd = it_peryear-period.

    LOOP AT r_yr WHERE low = it_peryear-gjahr.

    w_per-period = it_peryear-period.

    IF w_change = ''.

    w_per-year = r_yr-low.

    ENDIF. " IF w_change = ''

    IF w_per-period = 12.

    IF s_per-low <> w_per-period.

    • r_yr-low = r_yr-low - 1.

    w_change = 'X'.

    ENDIF. " IF s_per-low <> w_per-period

    w_per-year = r_yr-low.

    ENDIF. " IF w_per-period = 1

    CLEAR: w_invtot,

    w_cogstot.

    *-For each period populate the Credit and Debit info

    DO 12 TIMES.

    w_period-period = it_peryear-period.

    w_period-year = r_yr-low.

    CLEAR: w_amt,w_debit,w_bal1.

    CONCATENATE 'WA_INV-TSL' w_period-period+1(2) INTO w_amt.

    LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND

    drcrk = 'S' .

    ASSIGN (w_amt) TO <fs>.

    w_debit = w_debit + <fs>.

    UNASSIGN <fs>.

    CLEAR wa_inv-tslvt.

    ENDLOOP. " LOOP AT it_inv INTO wa_inv

    CLEAR: w_credit,w_bal2.

    LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND

    drcrk = 'H' .

    ASSIGN (w_amt) TO <fs>.

    <fs> = <fs> * -1.

    w_credit = w_credit + <fs>.

    UNASSIGN <fs>.

    CLEAR wa_inv-tslvt.

    ENDLOOP. " LOOP AT it_inv INTO wa_inv

    w_period-tsl01 = w_debit - w_credit.

    CLEAR w_amt.

    CONCATENATE 'WA_COG-TSL' w_period-period+1(2) INTO w_amt.

    LOOP AT it_cogs INTO wa_cog WHERE ryear = w_period-year.

    ASSIGN (w_amt) TO <fs>.

    w_period-tsl02 = w_period-tsl02 + <fs>.

    UNASSIGN <fs>.

    ENDLOOP. " LOOP AT it_cogs INTO wa_cog

    *-Calculate the total amounts

    w_invtot = w_invtot + w_period-tsl01.

    w_cogstot = w_cogstot + w_period-tsl02.

    APPEND w_period TO it_year_per.

    CLEAR: w_period-tsl02,w_period-tsl01.

    IF it_peryear-period EQ 1.

    it_peryear-period = 12.

    r_yr-low = r_yr-low - 1.

    ELSE.

    it_peryear-period = it_peryear-period - 1.

    ENDIF. " IF it_peryear-period

    ENDDO. " DO 12 TIMES.

    lv_period = w_per-period.

    lv_year = w_per-year.

    DO 12 TIMES.

    READ TABLE it_balance INTO wa_balance

    WITH KEY period = lv_period

    gjahr = lv_year.

    • w_per-invtot = w_invtot .+ wa_balance-tslvt.

    w_per-invtot = w_per-invtot + wa_balance-tslvt.

    IF lv_period = 1.

    lv_period = 12.

    lv_year = lv_year - 1.

    ELSE.

    lv_period = lv_period - 1.

    ENDIF. " IF lv_period = 1

    CLEAR wa_balance-tslvt.

    ENDDO. " DO 12 TIMES

    w_per-cogs = w_cogstot.

    w_per-invavg = w_per-invtot / 12.

    IF w_per-invavg NE 0.

    w_per-invturn = w_per-cogs / w_per-invavg.

    ENDIF. " IF w_per-invavg NE 0

    w_per-year = it_peryear-gjahr.

    w_per-info = it_year_per.

    APPEND w_per TO it_per.

    CLEAR: w_per-period,

    w_per-invtot,

    w_per-invavg,

    w_per-cogs,

    w_per-invturn,

    w_per-info,it_year_per.

    ENDLOOP. " LOOP AT r_yr WHERE

    ENDLOOP. " LOOP AT it_peryear

    ENDFORM. " POPULATE_PERIOD_DATA

    &----


    *& Form create_chart

    &----


    • Display the Chart

    ----


    FORM create_chart USING p_html TYPE w3htmltabtype p_real.

    DATA:

    igs_chart TYPE REF TO cl_igs_chart,

    line TYPE igs_data,

    data TYPE igs_data_tab,

    ext_line TYPE igs_ext,

    extension TYPE igs_ext_tab,

    mime TYPE w3mimetabtype,

    html TYPE w3htmltabtype,

    html_line TYPE w3html,

    url TYPE w3url,

    content_length TYPE i,

    content_type TYPE w3param-cont_type,

    content_subtype TYPE w3param-cont_type.

    DATA: val TYPE char30.

    • empty result table

    REFRESH p_html.

    • create chart object

    CREATE OBJECT igs_chart.

    • set chart type

    igs_chart->type = cl_igs_chart=>co_type_lines.

    • set picture size

    igs_chart->width = 640.

    igs_chart->height = 480.

    • igs_chart->width = 1024.

    • igs_chart->height = 680.

    • data to be displayed in the form of Graph

    SORT it_per BY period.

    LOOP AT it_per INTO w_per.

    line-groupid = w_per-year.

    line-x = w_per-period.

    IF w_per-invturn < 0.

    w_per-invturn = w_per-invturn * -1.

    CLEAR val.

    val = w_per-invturn .

    CONCATENATE '-' val INTO line-y.

    ELSE.

    line-y = w_per-invturn.

    ENDIF. " IF w_per-invturn < 0

    • BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419

    • To dislay the values in Graph

    line-DATALABEL = line-y.

    condense line-datalabel.

    • END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419

    APPEND line TO data.

    CLEAR line.

    ENDLOOP. " LOOP AT it_per INTO w_per

    *-Populate the IGS data

    igs_chart->data = data.

    • set titles

    igs_chart->title = 'Inventory Turns'.

    igs_chart->title_values = 'No of Turns'.

    igs_chart->title_categories = 'Period'.

    • create picture

    CALL METHOD igs_chart->send

    IMPORTING

    content_type = content_type

    content_length = content_length

    content = mime

    imagemap = html

    EXCEPTIONS

    rfc_communication_error = 1

    rfc_system_error = 2

    internal_error = 3

    OTHERS = 4.

    IF sy-subrc IS INITIAL AND p_real NE space.

    SPLIT content_type AT '/' INTO content_type content_subtype.

    CALL METHOD html_control->load_data

    EXPORTING

    type = content_type

    subtype = content_subtype

    size = content_length

    IMPORTING

    assigned_url = url

    CHANGING

    data_table = mime.

    CONCATENATE

    '<HTML><HEAD><TITLE>SAP IGS Chart</TITLE></HEAD>'

    '<BODY BGCOLOR=#DEDEC8>'

    '<MAP NAME=chart>'

    INTO html_line-line.

    APPEND html_line TO p_html.

    APPEND LINES OF html TO p_html.

    CONCATENATE

    '</MAP>'

    '<IMG SRC="' url '" USEMAP=#chart BORDER=0>'

    '</BODY></HTML>'

    INTO html_line-line.

    APPEND html_line TO p_html.

    ENDIF. " IF sy-subrc IS INITIAL AND..

    ENDFORM. " create_chart

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • Status and Controls Initialzation

    ----


    MODULE status_0100 OUTPUT.

    SET PF-STATUS 'ZTURN'.

    SET TITLEBAR 'ZTURN'.

    DATA: layout TYPE lvc_s_layo.

    *-Create the Container

    CREATE OBJECT cont

    EXPORTING

    container_name = 'CONT'

    EXCEPTIONS

    cntl_error = 1

    cntl_system_error = 2

    create_error = 3

    lifetime_error = 4

    lifetime_dynpro_dynpro_link = 5

    OTHERS = 6

    .

    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. " IF sy-subrc NE 0

    *-If Report option

    IF p_rep EQ 'X'.

    *-Creation of Grid Object

    CREATE OBJECT grid

    EXPORTING

    i_parent = cont

    EXCEPTIONS

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    OTHERS = 5

    .

    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. " IF sy-subrc NE 0

    layout-zebra = 'X'.

    layout-no_headers = 'X'.

    layout-cwidth_opt = 'X'.

    layout-grid_title = 'Inventory Turns Report'.

    *-Display the ALV

    grid->set_table_for_first_display(

    EXPORTING

    is_layout = layout

    CHANGING

    it_outtab = it_final

    it_fieldcatalog = it_fieldcat

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    ).

    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. " IF sy-subrc NE 0

    *-If Graph Option selected

    ELSEIF p_grp EQ 'X'.

    • set rfc destination

    cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.

    • create hmtl control

    CREATE OBJECT html_control

    EXPORTING parent = cont.

    PERFORM create_chart USING g_html 'X'.

    • get url of output data

    CALL METHOD html_control->load_data

    EXPORTING

    type = 'text'

    subtype = 'html'

    IMPORTING

    assigned_url = g_url

    CHANGING

    data_table = g_html.

    • Load the picture by using the url generated by the data .

    CALL METHOD html_control->show_url

    EXPORTING

    url = g_url.

    *-If Both Report and Graph Selected

    ELSE.

    • set rfc destination

    cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.

    • Create Splitter for custom_container

    CREATE OBJECT split

    EXPORTING

    parent = cont

    rows = 2

    columns = 1.

    CALL METHOD split->get_container

    EXPORTING

    row = 1

    column = 1

    RECEIVING

    container = htmlcon.

    CALL METHOD split->get_container

    EXPORTING

    row = 2

    column = 1

    RECEIVING

    container = gridcon.

    • create hmtl control

    CREATE OBJECT html_control

    EXPORTING parent = htmlcon.

    PERFORM create_chart USING g_html 'X'.

    • get url of output data

    CALL METHOD html_control->load_data

    EXPORTING

    type = 'text'

    subtype = 'html'

    IMPORTING

    assigned_url = g_url

    CHANGING

    data_table = g_html.

    • Load the picture by using the url generated by the data .

    CALL METHOD html_control->show_url

    EXPORTING

    url = g_url.

    CREATE OBJECT grid

    EXPORTING

    i_parent = gridcon

    EXCEPTIONS

    error_cntl_create = 1

    error_cntl_init = 2

    error_cntl_link = 3

    error_dp_create = 4

    OTHERS = 5

    .

    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. " IF sy-subrc NE 0

    layout-zebra = 'X'.

    layout-no_headers = 'X'.

    layout-cwidth_opt = 'X'.

    layout-grid_title = 'Inventory Turns Report'.

    grid->set_table_for_first_display(

    EXPORTING

    is_layout = layout

    CHANGING

    it_outtab = it_final

    it_fieldcatalog = it_fieldcat

    EXCEPTIONS

    invalid_parameter_combination = 1

    program_error = 2

    too_many_lines = 3

    ).

    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. " IF sy-subrc NE 0

    ENDIF. " IF p_rep EQ 'X'

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • User Action Handling

    ----


    MODULE user_command_0100 INPUT.

    CASE sy-ucomm.

    *-Handling the User actions

    WHEN 'BACK' OR 'CANC' OR 'EXIT'.

    LEAVE TO SCREEN 0.

    ENDCASE. " CASE sy-ucomm

    ENDMODULE. " USER_COMMAND_0100 INPUT

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.