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 Integrating 3 Internal Tables to make data for email attachment

Former Member
0 Kudos

Hi All,

I am facing a problem. I am having some data in 3 internal tables. Consider it Header Data, Details Data, Tail Data in 3 different Internal tables with different Fields.

Now I want to send this data as an attachment in email. Now the problem is I am integrating the data in 3 internal tables into 1 single internal table with the help of following code :

loop at it1.

concatenate it1-field1

it1-field2

into itab.

append itab.

endloop.

loop at it2.

concatenate it2-field1

it2-field2

into itab.

append itab.

endloop.

similarly for 3rd internal table. But here it goes wrong.

For each and every field in each record, some specific number of characters are fixed. If any field doesn't uses those characters to complete, it has to leave the remaining characters blank and should start next field from there.

E.g.

Like record is :

AAA reserved chars : 10

XXX " " : 15

YYY " " : 8

so it should print like :

AAA XXX YYY .

But in attachment it is printing like :

AAAXXXYYY.

This is because I am using concatenate function. Please suggest me a way to integrate the data of 3 internal tables into a single internal table including the spaces reserved for each field.

Thanks.

1 ACCEPTED SOLUTION

0 Kudos

Hi Ravi,

Did u try to use de addicion 'Separated by space' in the concatenate function?

If it doesn't work, try this...

You have to do as if you want to create a text file, using de offset function.

Creating an internal table with one field and put all the records of your tables into this internal table.

data: wa_line(400).

data: begin of itab_line occurs 0,

line(400),

endif itab_line.

Loop at itab1.

clear wa_line.

write: itab1-field1 to wa_line+0(10).

write: itab1-field2 to wa_line+10(8).

.

.

.

write: itab1-fieldN to wa_line+nn(mm).

append wa_line to itab_line.

clear itab_line.

endloop.

Do the same with itab2 and itab3.

Cheers,

FC.

5 REPLIES 5

Former Member
0 Kudos

in your concatenate statement

use

concatenate it1-field1
it1-field2
into itab <b>separated by space</b>.

0 Kudos

Hi Ravi,

Did u try to use de addicion 'Separated by space' in the concatenate function?

If it doesn't work, try this...

You have to do as if you want to create a text file, using de offset function.

Creating an internal table with one field and put all the records of your tables into this internal table.

data: wa_line(400).

data: begin of itab_line occurs 0,

line(400),

endif itab_line.

Loop at itab1.

clear wa_line.

write: itab1-field1 to wa_line+0(10).

write: itab1-field2 to wa_line+10(8).

.

.

.

write: itab1-fieldN to wa_line+nn(mm).

append wa_line to itab_line.

clear itab_line.

endloop.

Do the same with itab2 and itab3.

Cheers,

FC.

0 Kudos

Hi Francisco,

your idea worked, but now I am facing another problem.

I declared a variable wa_line(400) type c,

Also I declared an internal table

begin of itab occurs 0,

ws_line(400) type c,

end of itab.

now the data in each reocrd is of length 281, while mu record is stripped after around 245-250 characters. I think the internal table is not allowing the length if variable ws_line of 400. It is taking just 255 characters.

Please help how could I get the data of 281 characters in the file. Thanks.

Former Member
0 Kudos

Hi Mr:Ahuja,

Here I am giving a code which satisfies exactly your requirement. Use this logic for your 3 tables.

DATA:wa_sflight TYPE sflight.

DATA:wrk_string TYPE c LENGTH 100.

SELECT SINGLE * FROM sflight INTO wa_sflight.

DATA:lv_count TYPE i,

lv_len TYPE i,

lv_var TYPE i.

FIELD-SYMBOLS: <fs> TYPE ANY.

DO.

lv_count = lv_count + 1.

ASSIGN COMPONENT lv_count OF STRUCTURE wa_sflight TO <fs>.

IF sy-subrc NE 0.

EXIT.

ENDIF.

IF lv_count = 1.

lv_var = 0.

ELSE.

lv_var = lv_var + lv_len.

ENDIF.

DESCRIBE FIELD <fs> LENGTH lv_len IN BYTE MODE.

wrk_string+lv_var(lv_len) = <fs>.

ENDDO.

WRITE: wrk_string.

Rewards if find useful..

Regards,

Antony Thomas

raviahuja
Contributor
0 Kudos

Done