Dynamic ALV as per the periods on the selection screen

Hello Experts
I am new to dynamic ALV , Please help me to sought out my confusion.
I want to create a dynamic ALV , based on the period mentioned at selection screen.
for example I want to display the movement type  ( sum of the quantity ) for materials for the full month.
I want the ALV output as below.
Material  .........qty 01.04.2011..... qty 02.04.2011... qty 03.04.2011 ........ qty 30.04.2011
AB1........................... 30.................... 20............................. 50......................... 200
AB2.................................................... 50 ............................. 80 ..........................10
I create an internal table itab with there fields to selact the data
MATNR
date
qty
select MATNR
       date
       qty
into itab
from mseg
where based on the selection screen.
then collect the data to other table date wise , now i have summrise data of material quantity
now the results after collection data into table itab2 is as follows
Material  ................... date ................................   qty
AB1  ....................    01.04.2011.......................  30
AB1  ...................     02.04.2011 ....................... 20
AB1  ...................   03.04.2011.......................  50
AB1  ...................   .30.04.2011.......................  200
AB2 ....................   02.04.2011.......................   50
AB2 .......................   03.04.2011.......................   80
AB2 .......................   30.04.2011 .......................   10
How can I display these fields horizontally instead of vertically ,
and to the exact column as per the field catalog column header belongs to date.
it would be so helpful if somebody explain with code by taking the above example.
Thanks in Advance

Hello Both Experts ,
I write the below code and it is working for the requirement.
Can you please check
REPORT  z_test_dynamic                          .
TABLES : mkpf , mseg .
TYPES : BEGIN OF t_mseg ,
      mblnr TYPE mblnr ,
      bwart TYPE bwart ,
      matnr TYPE matnr ,
      werks TYPE werks_d ,
      menge TYPE menge_d ,
      budat TYPE budat ,
  END OF t_mseg.
TYPES : BEGIN OF t_mseg_1 ,
      matnr TYPE matnr ,
      menge TYPE menge_d ,
      budat TYPE budat ,
  END OF t_mseg_1.
DATA : gt_mseg TYPE STANDARD TABLE OF t_mseg ,
       gs_mseg TYPE t_mseg,
       gt_mseg_1 TYPE STANDARD TABLE OF t_mseg_1 ,
       gs_mseg_1 TYPE t_mseg_1,
       gt_mseg_2 TYPE STANDARD TABLE OF t_mseg_1 ,
       gs_mseg_2 TYPE t_mseg_1..
DATA : gt_date TYPE STANDARD TABLE OF sy-datum ,
      gs_date TYPE sy-datum..
DATA: ok_code LIKE sy-ucomm,
      g_container TYPE scrfname VALUE 'CONTAINER_01',
      grid1  TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gp_table TYPE REF TO data.
FIELD-SYMBOLS: <gt_table> TYPE table.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR mseg-matnr ,
                 s_bwart FOR mseg-bwart NO INTERVALS,
                 s_werks FOR mseg-werks ,
                 s_budat FOR mkpf-budat .
PARAMETERS   : p_mjahr TYPE mjahr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
PERFORM field_catalog.
CALL METHOD cl_alv_table_create=>create_dynamic_table
  EXPORTING
    it_fieldcatalog = gt_fieldcat
  IMPORTING
    ep_table        = gp_table.
ASSIGN gp_table->* TO <gt_table>.
PERFORM select_main_data.
PERFORM move_data.
*&      Form  select_main_data
*       text
*  -->  p1        text
*  <--  p2        text
FORM select_main_data .
  SELECT      mseg~mblnr
      mseg~bwart
      mseg~matnr
      mseg~werks
      mseg~menge
      mkpf~budat
    INTO TABLE gt_mseg
    FROM mseg AS mseg INNER JOIN mkpf AS mkpf
    ON mseg~mblnr = mkpf~mblnr AND
       mseg~mjahr = mkpf~mjahr
    WHERE matnr IN s_matnr AND
         budat IN s_budat AND
         werks IN s_werks AND
         bwart IN s_bwart AND
         mseg~mjahr EQ p_mjahr .
  IF  gt_mseg IS NOT INITIAL.
    LOOP AT gt_mseg INTO gs_mseg.
      gs_mseg_1-matnr = gs_mseg-matnr.
      gs_mseg_1-budat = gs_mseg-budat.
      gs_mseg_1-menge = gs_mseg-menge.
      COLLECT gs_mseg_1 INTO gt_mseg_1.
    ENDLOOP.
  ENDIF.
  gt_mseg_2 = gt_mseg_1.
  DELETE ADJACENT DUPLICATES FROM gt_mseg_2  COMPARING matnr.
ENDFORM.                    " select_main_data
*&      Form  field_catalog
*       text
*  -->  p1        text
*  <--  p2        text
FORM field_catalog .
  DATA : lt_day_attributes TYPE STANDARD TABLE OF casdayattr ,
         ls_day_attributes TYPE casdayattr .
  DATA: ls_fieldcat TYPE lvc_s_fcat ,
        lv_fieldname TYPE lvc_fname.
  IF s_budat-high IS INITIAL.
    s_budat-high = s_budat-low.
  ENDIF.
  CALL FUNCTION 'DAY_ATTRIBUTES_GET'
   EXPORTING
*   FACTORY_CALENDAR                 = ' '
*   HOLIDAY_CALENDAR                 = ' '
     date_from                        = s_budat-low
     date_to                          = s_budat-high
     language                         = sy-langu
* IMPORTING
*   YEAR_OF_VALID_FROM               =
*   YEAR_OF_VALID_TO                 =
*   RETURNCODE                       =
    TABLES
      day_attributes                   = lt_day_attributes
* EXCEPTIONS
*   FACTORY_CALENDAR_NOT_FOUND       = 1
*   HOLIDAY_CALENDAR_NOT_FOUND       = 2
*   DATE_HAS_INVALID_FORMAT          = 3
*   DATE_INCONSISTENCY               = 4
*   OTHERS                           = 5
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  LOOP AT lt_day_attributes INTO ls_day_attributes.
    gs_date = ls_day_attributes-date.
    APPEND gs_date TO gt_date.
  ENDLOOP.
  ls_fieldcat-fieldname = 'MATNR'.
  ls_fieldcat-inttype    = 'CHAR18'.
  ls_fieldcat-coltext    = 'MATERIAL'.
*   ls_fieldcat-decimals_o   = '2'.
  ls_fieldcat-outputlen = 18.
  APPEND ls_fieldcat TO gt_fieldcat.
  LOOP AT gt_date INTO gs_date.
    CONCATENATE 'QTY_' gs_date INTO lv_fieldname.
    ls_fieldcat-fieldname = lv_fieldname.
    ls_fieldcat-inttype    = 'QUAN'.
    ls_fieldcat-coltext    = gs_date.
    ls_fieldcat-decimals_o   = '2'.
*    ls_fieldcat-outputlen = 18.
    APPEND ls_fieldcat TO gt_fieldcat.
  ENDLOOP.
ENDFORM.                    " field_catalog
*&      Form  move_data
*       text
*  -->  p1        text
*  <--  p2        text
FORM move_data .
  DATA: l_row TYPE sy-index.
  FIELD-SYMBOLS: <ls_table>.
  FIELD-SYMBOLS: <l_field> ,
                 <l_mseg_1> TYPE t_mseg_1.
  DATA: ls_fieldcat TYPE lvc_s_fcat .
  ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <ls_table>.
  SORT gt_mseg_1 BY matnr.
  LOOP AT gt_mseg_1 ASSIGNING <l_mseg_1> .
    IF <l_field> IS ASSIGNED.
      UNASSIGN <l_field>.
    ENDIF.
    MOVE-CORRESPONDING <l_mseg_1> TO <ls_table>.
      READ TABLE gt_fieldcat INTO ls_fieldcat WITH KEY coltext = <l_mseg_1>-budat.
      IF sy-subrc EQ 0.
        ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <ls_table> TO <l_field>.
        <l_field> = <l_mseg_1>-menge.
      ELSE.
        <l_field> =  0.
      ENDIF.
    AT end of matnr.
      APPEND <ls_table> TO <gt_table>.
clear <ls_table>.
    ENDAT.
  ENDLOOP.
ENDFORM.                    " move_data
your answers help me lot . I am awarding the points.
Very Very Thanks
Edited by: Dilraj Singh on Apr 13, 2011 3:58 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:09 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:23 PM

Similar Messages

  • F.01 (RFBILA00) not taking the period specified on selection screen for com

    Hi Experts,
    Whenever we execute this report, it always takes the output from the start of the year. It does not take into account the u201Cfromu201D and u201CTou201D period which we specify on the selection screen.
    How to modify this report? Not able to find any relevant OSS note for it.
    Cheers,
    Nand

    Hi,
    In this report, go to tab u201CSpecial Evaluationu201D and give the u201CBalance Sheet Typeu201D as 2 Flow of funds analysis
    The system by default takes the type as 1 Standard financial statement, which means that an accumulated balance sheet is created, that is, the balance is calculated from the balance carried forward plus the periods 01 to the upper limit of the reporting and comparison periods you have specified.
    u201CBalance Sheet Typeu201D as 2 Flow of funds analysis means that a flow of funds analysis is created, that is, the balance is calculated from the reporting and comparison periods you specified.
    Regards,
    Gaurav

  • When the asset is sold in the mid of the period, how the depreciation is ca

    when the asset is sold in the mid of the period, how the depreciation is calculated as you can not run AFAB in the mid of the period.

    Adding to the above reply, when the asset is sold in the mid period, during such sale process, based on the period control, depreciation till the date will be computed by the system and adjusted.

  • Can we do cancellation of  invoice for the period preceding the transaction

    Hi All,
    Can we do cancellation of  invoice for the period preceding the transaction after the closing MMPV?
    Thanks,
    Praveen

    Hi,
    Unfortunately the answer is no. Two reasons for it.
    a. The period for which you want to post is already closed
    b. The period for which you want to reverse the invoice falls before the period your invoice is created (as I have understood your question) which is not allowed....
    Hope this helps
    Thanks
    Mukund S

  • Hello sir Every time I do the process of registration in Mogah Apple Store and the period and the period of the account is lost I do not know what the problem is there are people who enter into my account and change email We ask God to help you have an ac

    Hello sir Every time I do the process of registration in Mogah Apple Store and the period and the period of the account is lost I do not know what the problem is there are people who enter into my account and change email We ask God to help you have an account I can not restore it the way I do not know where and I do not speak English Aalit Aalit help me I'm in a state of panic for your reply eagerly awaited
    This old Emily Hope you reply and help me [email protected]

    For what it's worth, you posted this in 2011, and here in 2014 I am still having this same issue. Over the last two days, I have had to unlock my apple account 8 times. I didn't get any new devices. I haven't initiated a password reset. I didn't forget my password. I set up two factor authentication and have been able to do the unlocking with the key and using a code sent to one of my devices. 
    That all works.
    It's this having to unlock my account every time I go to use any of my devices. And I have many: iMac, iPad, iPad2, iPad mini, iPhone 5s, iPod touch (daughter), and my old iPhone 4 being used as an ipod touch now.  They are all synced, and all was working just fine.
    I have initiated an incident with Apple (again) but I know they are just going to suggest I change my Apple ID. It's a simple one, and one that I am sure others think is theirs. I don't want to change it. I shouldn't have to. Apple should be able to tell me who is trying to use it, or at least from where.
    Thanks for listening,
    Melissa

  • The accounting is apportioned across the period of the advance charge.

    Hi All,
    We have a new requirement from the business which is as below
    When invoicing in advance, say quarterly, the accounting is apportioned across the period of the advance charge ie if we invoice for Rent in Advance at the beginning of December for the period 25th December 2009 to 24th March 2010 inclusive, the apportionment to the accounts should be:
    7 days in December;
    31 days in January;
    28 days in February and
    24 days in March.
    If any one of you have come accross such type of requirment, your inputs given/provided would be much appreciated.
    Thanks and Regards
    Sri

    Hi all
    Can any one let me know how can I go ahead with this requirement
    Thnks and Rgds
    Sri

  • How to Improve the performance in Variable Selection Screen.

    Hi,
    In Query Level we have Variable " User entry Defalt Valu". User want select particular value when he press "F4" it's take hours time how to improve the performance in Varaible Selection Screen.
    Thanks in Advance.
    Regards,
    Venkat.

    Dear Venkat.
    You please try the following steps:
    1. Say the InfoObject is 0EMPLOYEE against which you have created the variable, which user is trying to select value against, when they execute the report.
    2. Goto RSA1-> InfoObject tab-> Select InfoObject 0EMPLOYEE.
    3. Selcet the following options:
       Query Execution Filter Val. Selectn  -  'Only Posted Value for Navigation'
       Filter Value Repr. At Query Exec. -      'Selector Box Without Values'
    Please let me know if there is any more issue. Feel free to raise further concern
    Thnx,
    Sukdev K

  • How to make the obligate field in selection screen

    Hi ,
    In my report two radio buttons and two bloc selection screens are there.When we select the first radio button first screen will be editable second screen will be non-editable vice-versa.
    but the problem is in each selection screen one mandatory field is required  suppose if i give the one field obligatory in first block screen it is not allowing the second readout please help me regarding this how i will make the mandatory field in both screens.
    Thanks,
    Harinath

    Hi...
    Dont Declare your field as OBLIGATORY.
    Instead perform the validation in AT SELECTION-SCREEN event. But validation should be only when Particular Radiobutton is selected.
    And Generate only Error Message (Type E).
    Try this code:
    AT SELECTION-SCREEN on <yOUR mandatory field>.
       IF PA_UPD = 'X'.
             IF <YOUR MANDATORY FIELD>  IS INITIAL.
                  Message 'Entry is must in this field' type 'E'.
             ENDIF.
       ENDIF.
    AT SELECTION-SCREEN OUTPUT.
    IF pa_udp = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-active = 1.
    ELSEIF screen-group1 = 'DEF'.
    screen-input = 0.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ELSEIF pa_rep = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-input = 0.
    ELSEIF screen-group1 = 'DEF'.
    screen-active = 1.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ENDIF.
    <b>Reward if Helpful</b>

  • How to get two parameters in the same line of selection screen?

    hello
    i need to get my selection csreen like bellow.
    r1 radiobuttion  -some space --p1 parameter
    i should not get the parameter in the next line of  radiobuttion.
    how to get two parameters in the same line of selection screen?

    hi....
    modify the following code
    it will work
    SELECTION-SCREEN BEGIN OF BLOCK SL1 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 10(15) TEXT-001
                     FOR FIELD P1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS : P1 TYPE   C USER-COMMAND R2 RADIOBUTTON GROUP R2 DEFAULT 'X',
      P2 TYPE SCARR-CARRNAME,
      P3 TYPE CHAR1 RADIOBUTTON GROUP R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK SL1.

  • How to color the text element in selection screen

    hi,
    i am going to pass some text element in selection screen output  and my requiremnt is text element should be given some colour.
    plz guide me.
    regards
    muthuraman.d

    Hi...
    Dont Declare your field as OBLIGATORY.
    Instead perform the validation in AT SELECTION-SCREEN event. But validation should be only when Particular Radiobutton is selected.
    And Generate only Error Message (Type E).
    Try this code:
    AT SELECTION-SCREEN on <yOUR mandatory field>.
       IF PA_UPD = 'X'.
             IF <YOUR MANDATORY FIELD>  IS INITIAL.
                  Message 'Entry is must in this field' type 'E'.
             ENDIF.
       ENDIF.
    AT SELECTION-SCREEN OUTPUT.
    IF pa_udp = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-active = 1.
    ELSEIF screen-group1 = 'DEF'.
    screen-input = 0.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ELSEIF pa_rep = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'ABC'. "#CCE
    screen-input = 0.
    ELSEIF screen-group1 = 'DEF'.
    screen-active = 1.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ENDIF.
    <b>Reward if Helpful</b>

  • Dynamic Data selection for the Filed entered in Selection Screen.

    Hi All,
    My requirement is as follows.
    1 select options in Selection Screen for MATNR (SO_MATNR)
    1 parameter field in Selection Screen for entering a MARC field name. (P_FIELD)
    Now the Program has to display the values of this Field (Entered by the user as P_FIELD) from MARC table, where MATNR is in SO_MATNR.
    I understand that this would require a dynamic select statemant but could not figure out the correct way.
    Please help me with the code for this requirement
    Regards,
    Sunil

    Not sure If I understand correct, but here's an example on what I think you are looking for. I don't have an ECC system here (we're on CRM), but you should adept it to your tables and fieldname.
    TABLES: but000.
    DATA: lt_feld TYPE TABLE OF name_feld,
          lw_feld LIKE LINE OF lt_feld.
    SELECT-OPTIONS: so_part FOR but000-partner.
    PARAMETERS: field TYPE name_feld DEFAULT 'MC_NAME1'.
    SELECT (field) FROM but000
      INTO TABLE lt_feld
      WHERE partner IN so_part.
    LOOP AT lt_feld INTO lw_feld.
      WRITE:/1 lw_feld.
    ENDLOOP.

  • Error In Depreciation Run in the period 08  the following is the error

    Dear all
    While executing the Deperciation run in the bacground in the period 8 system througing a error message that the Object ORD 600020 has system status CRTD (Created).  According to this status, transaction 'FI: Postings' is not allowed. how do i resolve this issue.
    Can any one help me out this please. to post the depreciation for the year 2006 and till date.
    Rao
    Edited by: venkateshwararao Kongara on Nov 15, 2008 8:18 AM

    Please run the depr program under test mode with list assets checked and recreate the error. Then please send us the long text of the error message.
    Would you please check how is the ORD *** linked to Asset accounts?

  • Problem in seeing the periods in the cube output list

    Hi Gurus,
    I have done generic custom extraction for Z totals table into BW . There is one Balance field in totals table which i need to bring in BW as beg balance period 0. so i mapped balance field in Z totals to the beg balance object in BW3.5. Also mapped the fiscper,fiscyer field inthe extract structure to the 0fiscper and 0fiscyear in transfer rules.
    Strangely after my full load, am able to see the fiscper(mmm,yyyy) for 000.2005 after locking in the infopackage in the PSA. But when i update it to the data target (infocube) am NOT able to see the period column.
    Also tried checking the update rules, locked the fiscper time characteristic tab to 000/2005 and tried. still the same problem.
    Could any one help me in getting this period column inthe cube output list.
    Thnks
    Kumar.

    check that your 0fiscper in cube is mapped to 0fiscper from communication structure in update rules.
    Please give me the details of mappings you have
    Cheers
    SB

  • How to change the text in default selection screen

    Hi,
      I have created the default selection screen(using PNP Logical database) ,In that I wants to display 'Data Selection Period' instead of 'Period'.
    Please send me the related code.
    Thanks in advace
    mohan

    HR Logical Database is PNP
    Main Functions of the logical database PNP:
    Standard Selection screen
    Data Retrieval
    Authorization check
    To use logical database PNP in your program, specify in your program attributes.
    Standard Selection Screen
    Date selection
    Date selection delimits the time period for which data is evaluated. GET PERNR retrieves all records of the relevant infotypes from the database. When you enter a date selection period, the PROVIDE loop retrieves the infotype records whose validity period overlaps with at least one day of this period.
    Person selection
    Person selection is the 'true' selection of choosing a group of employees for whom the report is to run.
    Sorting Data·
    The standard sort sequence lists personnel numbers in ascending order.
    · SORT function allows you to sort the report data otherwise. All the sorting fields are from infotype 0001.
    Report Class
    · You can suppress input fields which are not used on the selection screen by assigning a report class to your program.
    · If SAP standard delivered report classes do not satisfy your requirements, you can create your own report class through the IMG.  
    regards
    vinod

  • How to change the description of a selection screen

    Hi , I created a selection screen with the description as 'Test' , now the program has grown real big . I want to change the desccription to something else as it shows at the top of the selection screen. Can this be done with out copying the program to a new progarm with a new description. I mean , is there a way to change the current description .
    Thank you .

    Hi
    in SE38 Enter the program name.
    Select the Radio button<b> Attributes.</b>
    Change the <b>Title </b>of the Program.
    This title will appear in the selection screen as well as the list by default.
    We can also set this TITLE dynamically using the command.
    SET TITLE-BAR 'T1'.  "double click on T1 and create (Activate) it.
    <b>reward if Helpful.</b>

Maybe you are looking for

  • Receiving error while updating a folder inside sharepoint list

    What my code does - runs through each folders present in a list, and if any of the folders are in the name with current year, then it shall be renamed, ie 2012 to 2012_Backup. Soon after it is renamed we will create a name folder named 2012 and I get

  • Downloading iTunes upgrade 7.1.1

    please help. for a few months now everytime i open iTunes it tells me there is an upgrade available which I have tried to download several times with no luck. now i have just bought a new iPod shuffle and cant use it! Everytime I try to download 7.1.

  • CCM configuration.

    Hi We are in SRM4.0, we plan to configure CCM . Do we need to define logical systems in SPRO for CCM as well. Regards Ashish

  • Color Swatches in Illustrator CS6

    I can only load some of the swatches for the color books into the swatches pallet. Most importantly I cannot load the pantone swatches. I just get a blank pallet. Any ideas as to what I am doing wrong here? Many thanks for any help that is forthcomin

  • How do i get my phone back if is stolen

    i whant to know if i lost my phone what can i do