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

append with condition

Former Member
0 Likes
2,181

hi i have to 2 tables 1 contains the text and the other my final output table

the report shud display line by line for the line items

if tried to do the code like this

data: j type i.

j = 1.

loop at it_lines.

*concatenate v_text it_lines into v_text separated by space.

wa_output-tdline = it_lines-tdline.

if j = 1.

modify it_output from wa_output transporting tdline

where tdname = it_stxh-tdname.

j = j + 1.

else.

append wa_output to it_output.

endif.

endloop.

so that first time it will modify the text column with the first line and the next corresponding lines will be appended but it s getting appended with some other sales order the text and sales order are mismatching and also the it_lines is of structure in which only the text can be maintained and there s no common fields between the tables how can i overcome ths error

7 REPLIES 7
Read only

Former Member
0 Likes
1,397

Use the read option for this .

f1 is the link between the two tables .

declare

data : cntr like Sy-tabix .

loop at itab.
Read table jtab with key f1 = itab-f1. " use this option

if sy-subrc eq 0.
jtab-fx = itab-fx.
append jtab / modify transporting index cntr . " cntr = sy-tabix.
endif.
endloop.

so only the values pertaining to criteria are entered into the table .

regards,

vijay.

Read only

0 Likes
1,397

what is this f1?

Read only

0 Likes
1,397

Hi,

Can u post how your internal tables are defined and can u be more clear on what is ur requirement.

Thanks

Rajasekhar

Read only

0 Likes
1,397

data: IT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE,

it_output is declared based on a structure

here i get the values of it_lines

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

ID = '0002'

LANGUAGE = SY-LANGU

NAME = it_stxh-tdname

OBJECT = 'VBBP'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER = header

TABLES

LINES = IT_LINES

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • NOT_FOUND = 4

  • OBJECT = 5

  • REFERENCE_CHECK = 6

  • WRONG_ACCESS_TO_ARCHIVE = 7

  • OTHERS = 8

.

in it_lines i will hav eonly text value bcos the structure is defined in that way

in it_output i have line item level data

i will modify the cotents with text if it s with the first loop , if there s so many liines maintained for a single line item i will append , when i do append it s appending with some other sales order's line ite.

Read only

0 Likes
1,397

This is the common field in both the tables like a unique key field .

regards,

vijay.

Read only

0 Likes
1,397

i said know there is no common fields between those two tables

Read only

Former Member
0 Likes
1,397

Hi,

Change the code like this and try:

loop at it_lines.

clear wa_output.

wa_output-tdline = it_lines-tdline.

if sy-tabix = 1.

modify it_output from wa_output transporting tdline

where tdname = it_stxh-tdname.

else.

move-corresponding wa_output to it_output.

append it_output.

clear it_output.

endif.

endloop.

Not sure of the result. Just check and inform us.

Regards

Subramanian