Application Development 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: 

ALV Grid Collect Statment for SUM the data.

Former Member
0 Kudos
295

Hellow Experts,

i am new to ABAP i have on programme which output is coming like ,


Prod.ID   ... .... ... Qnty in Date1 .. Qnty in  Date2... Qnty in Date3........Qnty in Date31.
0001                       12.1               0.00               10.1
0001                       12.1               0.00               10.1

I need the summestion of qnty against that date , and prodId should not repate my Output should be like this,


Prod.ID   ... .... ... Qnty in Date1 .. Qnty in  Date2... Qnty in Date3........Qnty in Date31.
0001                       24.2               0.00               20.2
0002                       12.1               0.00               10.1

I wrote collect statment but its not working , plz help me for this, and one more thing that i am passing the data to gt_data.

My code is here,


TABLES: AFRU,AUFK,VBAK,KNA1,VBAP,VBKD.
DATA: BEGIN OF i_alv OCCURS 0,
      ARBID TYPE AFRU-ARBID,
      BUDAT TYPE AFRU-BUDAT,
      WERKS TYPE AFRU-WERKS,
      LMNGA TYPE AFRU-LMNGA,
      AUFNR TYPE AFRU-AUFNR,
      KDAUF TYPE AUFK-KDAUF,
      KDPOS TYPE AUFK-KDPOS,
      VBELN TYPE VBAK-VBELN,
      KUNNR TYPE VBAK-KUNNR,
      NAME1 TYPE KNA1-NAME1,
      MATNR TYPE VBAP-MATNR,
      KDKG1 TYPE VBKD-KDKG1,
  end of i_alv.

TYPES: BEGIN OF ty_data,
         lmnga TYPE AFRU-LMNGA,
         BUDAT TYPE AFRU-BUDAT,
         ARBID TYPE AFRU-ARBID,
         aufnr TYPE AFRU-AUFNR,
         kdauf TYPE AUFK-KDAUF,
         name1 TYPE KNA1-NAME1,
         matnr TYPE VBAP-MATNR,
         kdkg1 TYPE VBKD-KDKG1,


       END OF ty_data,
       tt_data TYPE STANDARD TABLE OF ty_data,

       BEGIN OF ty_dyn1,                                    "#EC NEEDED
         ARBID TYPE AFRU-ARBID,
         aufnr TYPE AFRU-AUFNR,
         kdauf TYPE AUFK-KDAUF,
         name1 TYPE KNA1-NAME1,
         matnr TYPE VBAP-MATNR,
         kdkg1 TYPE VBKD-KDKG1,
       END OF ty_dyn1,

       BEGIN OF ty_dyn2,                                    "#EC NEEDED
         date  TYPE AFRU-LMNGA,
       END OF ty_dyn2,

       BEGIN OF ty_cols,
         date TYPE BUDAT,
       END OF ty_cols,
       tt_cols TYPE SORTED TABLE OF ty_cols WITH UNIQUE KEY date.

DATA: gt_data TYPE tt_data,
      gt_data2 type tt_data,
      gt_cols TYPE tt_cols,
      gs_col  TYPE ty_cols.

DATA: go_sdescr     TYPE REF TO cl_abap_structdescr,
      go_sdescr_new TYPE REF TO cl_abap_structdescr,
      go_tdescr     TYPE REF TO cl_abap_tabledescr,
      gdo_handle    TYPE REF TO data,
      gs_component  TYPE abap_compdescr,
      gs_comp       TYPE abap_componentdescr,
      gt_components TYPE abap_component_tab,
      gr_data       TYPE REF TO cl_salv_table,
      gr_funct      TYPE REF TO cl_salv_functions,
      gr_columns    TYPE REF TO cl_salv_columns_table,
      gr_column     TYPE REF TO cl_salv_column_table,
      g_col         TYPE lvc_fname,
      g_txt         TYPE scrtext_l.

FIELD-SYMBOLS: <t_data> TYPE ANY TABLE,
               <s_data> TYPE any,
               <c> TYPE any,
               <d> TYPE ty_data.
DATA:  pono TYPE ztecerti-pono,
       jobno TYPE ztecerti-jobno,

       sdk TYPE string,
       insert TYPE c,
       ok_code LIKE sy-ucomm.
CALL SCREEN 100.
START-OF-SELECTION.
* Populate test data
FORM get_data.
  SELECT A~ARBID
         A~BUDAT
         A~WERKS
         A~LMNGA
         A~AUFNR
         B~KDAUF
         B~KDPOS
         C~VBELN
         C~KUNNR
         D~NAME1
         E~MATNR
         F~KDKG1
    INTO CORRESPONDING FIELDS OF TABLE  gt_data
               FROM AFRU AS A INNER JOIN AUFK AS B ON A~AUFNR EQ B~AUFNR
                              INNER JOIN VBAK AS C ON B~KDAUF = C~VBELN
                              INNER JOIN KNA1 AS D ON C~KUNNR = D~KUNNR
                              INNER JOIN VBAP AS E ON B~KDAUF = E~VBELN
                              INNER JOIN VBKD AS F ON B~KDAUF = F~VBELN

  WHERE   A~ARBID = '10000181' AND  A~BUDAT BETWEEN  PONO AND jobno
  GROUP BY A~ARBID A~LMNGA  A~BUDAT A~WERKS  A~AUFNR B~KDAUF   F~KDKG1   E~MATNR  D~NAME1 C~KUNNR   C~VBELN  B~KDPOS
ORDER BY B~KDPOS.

*collect gt_data into gt_data2.



*gt_data

*LOOP AT gt_data ASSIGNING <d>.

ENDFORM.

Thanking you i realy need it badly

3 REPLIES 3

Former Member
0 Kudos
67

Answer is fully given here: ....

m.

0 Kudos
67

I am logged in and when I tried to reach the link it says I am unauthorized.

0 Kudos
67

Try Cross Tab Report Issue...

Regards,
Raymond