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

sorted table problem.

Former Member
0 Likes
1,789

My program is dumping while assinging 9767297 records from gt_kna1_ext to lt_kna1_ext by saying TSV_TNEW_PAGE_ALLOC_FAILED.

lt_kna1_ext[] = gt_kna1_ext[].

I have declared as

TYPES : BEGIN OF t_kna1_ext,

kunnr TYPE kunnr,

name2 TYPE name2_gp,

j_3astcu TYPE j_3astcu,

sales_org TYPE vkorg,

sold_to TYPE kunnr,

END OF t_kna1_ext.

DATA : gt_kna1_ext TYPE TABLE OF t_kna1_ext,

-


in subroutine declared as sorted table becasue later it has to be used to select from knvp table.

DATA : lt_kna1_ext TYPE SORTED TABLE OF t_kna1_ext WITH NON-UNIQUE KEY sold_to sales_org kunnr.

here while assiging dumping

lt_kna1_ext[] = gt_kna1_ext[].

DELETE ADJACENT DUPLICATES FROM lt_kna1_ext COMPARING sold_to sales_org kunnr.

*-KNVP table read----


IF NOT gt_kna1_ext[] IS INITIAL.

SELECT kunnr

vkorg

spart

parvw

kunn2

FROM knvp

INTO TABLE gt_knvp

FOR ALL ENTRIES IN lt_kna1_ext

WHERE kunnr = lt_kna1_ext-sold_to

AND vkorg = lt_kna1_ext-sales_org

AND spart = gc_01

AND parvw = gc_we

AND kunn2 = lt_kna1_ext-kunnr.

REFRESH : lt_kna1_ext.

LOOP AT gt_kna1_ext INTO gs_kna1_ext.

LOOP AT gt_knvp INTO wa_knvp

WHERE kunn2 = gs_kna1_ext-kunnr

AND vkorg = gs_kna1_ext-sales_org.

wa_knvp-j_3astcu = gs_kna1_ext-j_3astcu.

wa_knvp-name2 = gs_kna1_ext-name2.

MODIFY gt_knvp FROM wa_knvp

TRANSPORTING j_3astcu name2

WHERE kunnr = wa_knvp-kunnr

AND kunn2 = wa_knvp-kunn2

AND vkorg = wa_knvp-vkorg

AND spart = wa_knvp-spart

AND parvw = wa_knvp-parvw.

ENDLOOP. " LOOP AT gt_knvp INTO wa_knvp

ENDLOOP. " LOOP AT gt_kna1_ext INTO gs_kna1_ext.

ENDIF. " IF NOT gt_kna1[] IS INITIAL.

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,424

Hello,

A few points:

1. Why do you need to declare lt_kna1_ext as a SORTED TABLE??

Did you write :

SORT gt_kna1_ext BY sold_to sales_org kunnr statement i your code?

2. The below code will also serve your purpose.



DATA : lt_kna1_ext TYPE t_kna1_ext.

lt_kna1_ext[] = gt_kna1_ext[].

SORT lt_kna1_ext BY sold_to sales_org kunnr.

DELETE ADJACENT DUPLICATES FROM lt_kna1_ext COMPARING sold_to sales_org kunnr.

Hope this helps.

BR,

Suhas

10 REPLIES 10
Read only

nkr1shna
Contributor
0 Likes
1,424

HI Sam,

Please modify below statement which is between LOOP .. ENDLOOP construct.

MODIFY gt_knvp FROM wa_knvp

TRANSPORTING j_3astcu name2

WHERE kunnr = wa_knvp-kunnr

AND kunn2 = wa_knvp-kunn2

AND vkorg = wa_knvp-vkorg

AND spart = wa_knvp-spart

AND parvw = wa_knvp-parvw.

Instead of above statement, please use READ <Internal table> with BINARY SEARCH. then modify the internal table contents. Which does not use memory and works quicker to execute.

Let me know if you have further questions.

Best Regards,

Krishna

Read only

Former Member
0 Likes
1,424

Hi Sam,

Don't use Nested loops.

use read statement in place of second Loop.

before using read statement use can sort the internal table by key fields.

finally the statement will be as followed

clear : gt_knvp.

sort gt_knvp by kunnr sales_org.

LOOP AT gt_kna1_ext INTO gs_kna1_ext.

read table gt_knvp with kunn2 = gs_kna1_ext-kunnr

vkorg = gs_kna1_ext-sales_org binary search.

if sy-subrc = 0,

wa_knvp-j_3astcu = gs_kna1_ext-j_3astcu.

wa_knvp-name2 = gs_kna1_ext-name2.

MODIFY gt_knvp FROM wa_knvp

TRANSPORTING j_3astcu name2

WHERE kunnr = wa_knvp-kunnr

AND kunn2 = wa_knvp-kunn2

AND vkorg = wa_knvp-vkorg

AND spart = wa_knvp-spart

AND parvw = wa_knvp-parvw.

endif.

ENDLOOP. " LOOP AT gt_knvp INTO wa_knvp

try with the above code.

Regards

Sreeni

Read only

Former Member
0 Likes
1,424

offcourse thanks for your explanation.

My program is basically giving dump at

lt_kna1_ext[] = gt_kna1_ext[].

Kindly read my initial explanation ad suggest me.

THANKS IN ADVANCE

Read only

Former Member
0 Likes
1,424

Hi Sam,

Confirm the structure of both internal table is same.

Number of fileds should be same.

Regards,

Flavya

Read only

matt
Active Contributor
0 Likes
1,424

You've run out of memory. You either need to talk to basis to get more memory, or change your program to use less memory - selecting less data at one time. Did you try searching on "TSV_TNEW_PAGE_ALLOC_FAILED".

matt

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,425

Hello,

A few points:

1. Why do you need to declare lt_kna1_ext as a SORTED TABLE??

Did you write :

SORT gt_kna1_ext BY sold_to sales_org kunnr statement i your code?

2. The below code will also serve your purpose.



DATA : lt_kna1_ext TYPE t_kna1_ext.

lt_kna1_ext[] = gt_kna1_ext[].

SORT lt_kna1_ext BY sold_to sales_org kunnr.

DELETE ADJACENT DUPLICATES FROM lt_kna1_ext COMPARING sold_to sales_org kunnr.

Hope this helps.

BR,

Suhas

Read only

matt
Active Contributor
0 Likes
1,424

>

> Hello,

>

> A few points:

>

> 1. Why do you need to declare lt_kna1_ext as a SORTED TABLE??

>

> Did you write :

> SORT gt_kna1_ext BY sold_to sales_org kunnr statement i your code?

>

>

> 2. The below code will also serve your purpose.

>


> 
> DATA : lt_kna1_ext TYPE t_kna1_ext.
> 
> lt_kna1_ext[] = gt_kna1_ext[].
> 
> SORT lt_kna1_ext BY sold_to sales_org kunnr.
> 
> DELETE ADJACENT DUPLICATES FROM lt_kna1_ext COMPARING sold_to sales_org kunnr.
> 

>

> Hope this helps.

>

> BR,

> Suhas

So, Suhas, you suggest that Sam Kumar's good piece of programmer, where the definition of the data serves the purpose, be replaced with some bad piece of old fashioned programming? He uses SORTED so that he doesn't have to SORT it later. It's always best to be as specific as possible in your data definitions. Oh, and by the way, your code won't work. t_kna1_ext is a structure, not a table.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,424

Hello Matt,

My mistake ) Generally ppl use SORTED tables & get dumps. So i thought Sam might have commited the same error.

Thnx for correcting my post.

BR,

Suhas

Read only

Former Member
0 Likes
1,424

It is dumping at

lt_kna1_ext[] = gt_kna1_ext[].

I mean not even assigning.

not going to sort stmt at all

Read only

matt
Active Contributor
0 Likes
1,424

You know where it dumps, and from my previous answer, you know why.

You need to redo this bit

lt_kna1_ext[] = gt_kna1_ext[].
DELETE ADJACENT DUPLICATES FROM lt_kna1_ext COMPARING sold_to sales_org kunnr.

As there isn't enough memory allocated to hold BOTH tables. If lt_kna1_ext turns out to not contain too many records, this might work.


DATA : lt_kna1_ext TYPE SORTED TABLE OF t_kna1_ext WITH UNIQUE KEY sold_to sales_org kunnr,
      ls_kna1_ext TYPE t_kna1_ext.

LOOP AT gt_kna1_ext INTO ls_kna1_ext.
  READ TABLE lt_kna1_ext WITH TABLE KEY sold_to = ls_kna1_ext-soldto sales_org = ls_kna1_ext-sales_org kunnr = ls_kna1_ext-kunnr TRANSPORTING NO FIELDS.
  CHECK sy-subrc IS NOT INITIAL.
  INSERT ls_kna1_ext INTO TABLE lt_kna1_ext.
ENDLOOP.

I've changed the local definition to a UNIQUE key. It might be more efficient to define it as a HASHED table, but I can't remember if that works with "FOR ALL ENTRIES".