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: 

Problem in At End Of

Former Member
0 Kudos

Hi experts,

I hv one int table it_data with following entries.

ARTNR BUDAT VVVOL3 VVVOL_ME3

1010371 20070110 10 L

1010371 20070110 10 L

1010371 20070124 20 L

1010371 20070124 20 L

1012376 20070110 4 L

1012376 20070110 4 L

1012376 20070110 4 L

1012376 20070110 4 L

1012377 20070110 20 L

1012377 20070110 20 L

1012377 20070110 20 L

1012377 20070110 20 L

Now I want to do SUM of VVVOL3 for the same ARTNR and the BUDAT & VVVOL_ME3 ( posting date and unit )of last ARTNR to be taken

i.e. for ARTNR 1010371 the record should be

ARTNR BUDAT VVVOL3 VVVOL_ME3

1010371 20070124 60 L

So for that , I am using ..AT END OF. ....as below

Loop at it_data.

At end of artnr.

Sum.

move it_data-artnr to it_data1-artnr .

move it_data-budat to it_data1-budat .

move it_data-vvvol3 to it_data1-vvvol3.

move it_data-vvvol3_me to it_data1-vvvol3_me .

append it_data1.

clear it_data1.

clear it_data.

endloop.

But The corresponding BUDAT and VVVOL3_ME can not be taken in it_data1.

As inside ' AT END OF' fields witl data type DATS,UNIT,CUKY are filled with '**********'.

Could anybody suggest me a simpler solution?

Thanks...............

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use below code..


data : flag type c.

Loop at it_data.
  At end of artnr.
    flag = 'X'.
  end at.
  it_data1-vvvol3 = it_data1-vvvol3 + it_data-vvvol3 .
  if flag = 'X'.
    move it_data-artnr to it_data1-artnr . 
    move it_data-budat to it_data1-budat .
    move it_data-vvvol3_me to it_data1-vvvol3_me .
    append it_data1.
    clear it_data1.
    clear it_data.
  endif.
  clear flag.
endloop.

Hope it helps..

Regards,

Meet

7 REPLIES 7

Former Member
0 Kudos

Hi,

You have to get the content into the temporary work area before using AT END OF in Loop.

Loop at it_data.

wa_data = it_data.

AT END OF artnr.

move wa_data-artnr to it_data1-artnr .

move wa_data-budat to it_data1-budat .

move wa_data-vvvol3 to it_data1-vvvol3.

move wa_data-vvvol3_me to it_data1-vvvol3_me .

append it_data1.

clear it_data1.

clear wa_data.

endloop.

reagrds,

Dwaraka.S

Former Member
0 Kudos

Hi Ubhaka

Declare a worarea of type it_data.

then before AT statement move the contents of the headerline into the workarea.

Use the contents of this workarea in side the AT control break.

Pushpraj

0 Kudos

Hi,

First internal table should be sorted . Copy contents to workarea .

Refer this link .

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/frameset.htm

Former Member
0 Kudos

Hi,

Use below code..


data : flag type c.

Loop at it_data.
  At end of artnr.
    flag = 'X'.
  end at.
  it_data1-vvvol3 = it_data1-vvvol3 + it_data-vvvol3 .
  if flag = 'X'.
    move it_data-artnr to it_data1-artnr . 
    move it_data-budat to it_data1-budat .
    move it_data-vvvol3_me to it_data1-vvvol3_me .
    append it_data1.
    clear it_data1.
    clear it_data.
  endif.
  clear flag.
endloop.

Hope it helps..

Regards,

Meet

former_member1242340
Participant
0 Kudos

HI,

check out this code hopw this will help to you.

REPORT Z_RA_SUB_TOTAL NO STANDARD PAGE HEADING

LINE-COUNT 22(3)

LINE-SIZE 150.

****************TABLES**************

TABLES : KNA1, "GENERAL DATA IN CUSTOMER MASTER

VBAK. "SALES ORDER-HEADER DATA

TABLES : SPELL.

****************DATA TYPES**********

TYPES : BEGIN OF TY_ORDERS,

KUNNR TYPE KNA1-KUNNR, "CUSTOMER NUMBER

NAME1 TYPE KNA1-NAME1, "CUSTOMER NAME

ORT01 TYPE KNA1-ORT01, "CITY

LAND1 TYPE KNA1-LAND1, "COUNTRY

VBELN TYPE VBAK-VBELN, "ORDER NUMBER

ERDAT TYPE VBAK-ERDAT, "ORDER DATE

NETWR TYPE VBAK-NETWR, "ORDER VALUE

END OF TY_ORDERS.

****************WORK AREAS***************

DATA : W_ORDERS TYPE TY_ORDERS.

DATA : CURRENCY LIKE SPELL.

DATA : CURRENCY1 LIKE SPELL.

***************INTERNAL TABLES***********

DATA : T_ORDERS TYPE STANDARD TABLE OF TY_ORDERS

INITIAL SIZE 3.

***************SELECTION SCREENS************

SELECT-OPTIONS : S_CUSTNO FOR KNA1-KUNNR,

S_ORDNO FOR VBAK-VBELN.

SELECT-OPTIONS : S_CNTRY FOR KNA1-LAND1 NO INTERVALS.

***************REPORT EVENT*****************

INITIALIZATION.

S_CUSTNO-SIGN ='I'.

S_CUSTNO-OPTION = 'BT'.

S_CUSTNO-LOW = 1000.

S_CUSTNO-HIGH = 2000.

APPEND S_CUSTNO.

*****************REPORT EVENT****************

AT SELECTION-SCREEN.

IF S_CUSTNO-HIGH > 2000.

MESSAGE E004(Z10_ALMSG1).

ENDIF.

**************REPORT EVENT******************

TOP-OF-PAGE.

WRITE : /45 'CUSTOMER ORDER INFORMATION REPORT' COLOR 1 INVERSE ON.

ULINE.

WRITE : /03 'CUSTOMER NUMBER',

25 'CUSTOMER NAME',

53 'CITY',

80 'COUNTRY'.

SET LEFT SCROLL-BOUNDARY COLUMN 45.

WRITE : /100 'ORDER NUMBER',

117 'ORDER DATE',

140 'ORDER VALUE'.

ULINE.

************REPORT EVENT*******************

END-OF-PAGE.

ULINE.

WRITE : /45 'END OF PAGE:',SY-PAGNO.

ULINE.

************REPORT EVENT*******************

START-OF-SELECTION.

****************EXTRACT DATA****************

SELECT K~KUNNR

K~NAME1

K~ORT01

K~LAND1

V~VBELN

V~ERDAT

V~NETWR

INTO TABLE T_ORDERS

FROM KNA1 AS K

INNER JOIN

VBAK AS V

ON KKUNNR = VKUNNR

WHERE K~KUNNR IN S_CUSTNO

AND V~VBELN IN S_ORDNO.

***************DISPLAY DATA****************

NEW-PAGE LINE-COUNT SY-SROWS.

SORT T_ORDERS BY KUNNR.

LOOP AT T_ORDERS INTO W_ORDERS.

AT NEW KUNNR.

READ TABLE T_ORDERS INTO W_ORDERS WITH KEY KUNNR = W_ORDERS-KUNNR.

WRITE : /03 W_ORDERS-KUNNR,

25 W_ORDERS-NAME1,

53 W_ORDERS-ORT01,

80 W_ORDERS-LAND1.

ENDAT.

WRITE : /100 W_ORDERS-VBELN,

117 W_ORDERS-ERDAT,

140 W_ORDERS-NETWR.

****************GRAND TOTAL**************************

AT LAST.

SUM.

FORMAT COLOR 3.

WRITE : /'GRAND TOTAL ORDER VALUE:',130 W_ORDERS-NETWR.

FORMAT COLOR OFF.

ENDAT.

Former Member
0 Kudos

Hi,

you can try like this

delcare one more internal table & variable

data:it_data_new like it_data occurs 0 with header line,

val type vvvol3.

refresh:it_data_new.

sort it_data by artnr budat vvvol_me3.

it_data_new[] = it_data[].

delete adjacent duplicates from it_data comparing artnr budat vvvol_me3.

loop at it_data.

loop at it_data_new where artnr = it_data-artnr

and budat = it_data-budat

and vvvol_me3 = it_data-vvvol_me3.

val = val + it_data_new-vvvol3.

clear:it_data_new.

endloop.

move val to it_data-vvvol3.

modify it_data transporting vvvol3.

clear:val,it_data.

endloop.

now in internal table(it_data) you will get as per your requriment.

Regards,

Satya.

Former Member
0 Kudos

issue resolved....thanks for ur replies.......