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: 

How to write message?

Former Member
0 Kudos

Hi,

I have a problem in writting message after downloading. When the records of Customer download successful, the message" Customer code 1111111 download OK' will showed.

With the coding I wrote, Just only one customer code showed in the download message, and the other customer code which were download successful could not been showed.

Question: I need to show all the successful downloaded customer code, How can I correct the folloing coding?

Please help, thank you.

-


Data: anz_dl1(15) type n,

anz_dl2(15) type n.

BEGIN OF HTEXT1,

text1(30) VALUE 'customer code',

anzahl1(150),

text3(20) VALUE ' DOWNLOAD NG',

END OF HTEXT1,

BEGIN OF HTEXT2,

text3(30) VALUE 'customer code',

anzahl2(150),

text4(20) VALUE ' DOWNLOAD OK',

END OF HTEXT2.

CLEAR anz_dl1.

CLEAR htext1-anzahl1.

WRITE T1-KUNNR TO anz_dl1.

WRITE T-KUNNR TO anz_dl2.

WRITE anz_dl1 to htext1-anzahl1.

CONDENSE htext1.

WRITE anz_dl2 to htext2-anzahl2.

CONDENSE htext2.

IF p_downl = 'X'.

SKIP 2.

WRITE: / htext1.

SKIP 2.

WRITE:/ htext2.

-


1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi.

Declare two tables for each of the structures and add rows with Your data to them.

Latter make a loop at the tables with the CONDESE and display Your data.

Hope it helps.

-


Data: anz_dl1(15) type n,

anz_dl2(15) type n,

BEGIN OF HTEXT1,

text1(30) VALUE 'customer code',

anzahl1(150),

text3(20) VALUE ' DOWNLOAD NG',

END OF HTEXT1,

BEGIN OF HTEXT2,

text3(30) VALUE 'customer code',

anzahl2(150),

text4(20) VALUE ' DOWNLOAD OK',

END OF HTEXT2,

HTEXT1_TAB like TABLE OF HTEXT1,

HTEXT2_TAB like TABLE OF HTEXT2.

CLEAR anz_dl1.

CLEAR htext1-anzahl1.

WRITE T1-KUNNR TO anz_dl1.

WRITE T-KUNNR TO anz_dl2.

WRITE anz_dl1 to htext1-anzahl1.

APPEND htext1 to htext1_tab.

WRITE anz_dl2 to htext2-anzahl2.

APPEND htext2 to htext2_tab.

IF p_downl = 'X'.

LOOP AT htext1_tab INTO htext1.

CONDENSE htext1.

SKIP 2.

WRITE: / htext1.

ENDLOOP.

LOOP AT htext2_tab INTO htext2.

CONDENSE htext2.

SKIP 2.

WRITE:/ htext2.

ENDLOOP.

ENDIF.

-


Regards,

10 REPLIES 10

Former Member
0 Kudos

Hi.

Declare two tables for each of the structures and add rows with Your data to them.

Latter make a loop at the tables with the CONDESE and display Your data.

Hope it helps.

-


Data: anz_dl1(15) type n,

anz_dl2(15) type n,

BEGIN OF HTEXT1,

text1(30) VALUE 'customer code',

anzahl1(150),

text3(20) VALUE ' DOWNLOAD NG',

END OF HTEXT1,

BEGIN OF HTEXT2,

text3(30) VALUE 'customer code',

anzahl2(150),

text4(20) VALUE ' DOWNLOAD OK',

END OF HTEXT2,

HTEXT1_TAB like TABLE OF HTEXT1,

HTEXT2_TAB like TABLE OF HTEXT2.

CLEAR anz_dl1.

CLEAR htext1-anzahl1.

WRITE T1-KUNNR TO anz_dl1.

WRITE T-KUNNR TO anz_dl2.

WRITE anz_dl1 to htext1-anzahl1.

APPEND htext1 to htext1_tab.

WRITE anz_dl2 to htext2-anzahl2.

APPEND htext2 to htext2_tab.

IF p_downl = 'X'.

LOOP AT htext1_tab INTO htext1.

CONDENSE htext1.

SKIP 2.

WRITE: / htext1.

ENDLOOP.

LOOP AT htext2_tab INTO htext2.

CONDENSE htext2.

SKIP 2.

WRITE:/ htext2.

ENDLOOP.

ENDIF.

-


Regards,

0 Kudos

Hi Cywinski,

Thank you very much for your advice.

I corrected the coding as you advice.* The result is that still only one customer code, not all cusotmer code show in the message.*

I debuged it and saw there was only one recode in the table HTEXT1_TAB and table HTEXT2_TAB seperately. The other customer code were not in the tables.

Question Is that any problem in the fowllowing coding ?

It seem to me that T1-KUNNER The Customer code (T1-KUNNR) and customer code(T-KUNNR) was overwriten one by one?!

WRITE T1-KUNNR TO anz_dl1.

WRITE T-KUNNR TO anz_dl2.

How Can I correct it?

Please help. Thank you in advance.

0 Kudos

In Your code there is no declaration of T and T1 so

I can only assume that T and T1 are tables with Your results (i didn't saw that first time ;/ )

You have to assign all of the antries - not only one row.

-


For tables with the header lines:

LOOP AT T1.

WRITE T1-KUNNR TO anz_dl1.

WRITE anz_dl1 to htext1-anzahl1.

APPEND htext1 to htext1_tab.

ENDLOOP.

LOOP AT T.

WRITE T-KUNNR TO anz_dl2.

WRITE anz_dl2 to htext2-anzahl2.

APPEND htext2 to htext2_tab.

ENDLOOP.

-


If T and T1 are some structures than You have to declare them as a tables.

Regards,

0 Kudos

Hi Cywinshi,

Thank you for your guidance.

Under your help, all the customer codes has been showed out. Thank you . While, I have another question.

I would like to sum up the customer codes to avoid the repetition of the same customer codes.

I try to write like as following, but it did not work.

Could you please correct this?

-


SORT T1.

DELETE ADJACENT DUPLICATES FROM t1.

LOOP AT t1.

WRITE t1-kunnr TO anz_dl1.

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

ENDLOOP.

SORT T.

DELETE ADJACENT DUPLICATES FROM t.

LOOP AT t.

WRITE t-kunnr TO anz_dl2.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

ENDLOOP.

-


0 Kudos

Hi,

Check the below logic of using DELETE statement.

SORT T1 by KUNNR.

DELETE ADJACENT DUPLICATES FROM t1 COMPARING kunnr.

LOOP AT t1.

WRITE t1-kunnr TO anz_dl1.

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

ENDLOOP.

SORT T BY KUNNR.

DELETE ADJACENT DUPLICATES FROM t COMPARING kunnr.

LOOP AT t.

WRITE t-kunnr TO anz_dl2.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

ENDLOOP.

0 Kudos

Hi ,

Thank you for your e-mail.

I write the coding as following and the following and the outlook like this:

-


Outlook

11 records writen in file C:\TEMP\CU_CC2080_28012008_134446.txt

Customer code: 300100000 DOWNLOAD NG

Customer code: 000000000000000 DOWNLOAD NG

Customer code:300100005 DOWNLOAD OK

Customer code: 300100089 DOWNLOAD OK

Customer code: 000000000000000 DOWNLOAD OK

Customer code: 000000000000000 DOWNLOAD NG

-


My question is :

The customer code 000000000000000 do not exit, but it appear in the outlook for DOWNLOAD NG AND DOWNLOAD OK, how can I correct it?

The source code:

-


CLEAR anz_dl1.

LOOP AT t1.

WRITE t1-kunnr TO anz_dl1.

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

ENDLOOP.

SORT htext1_tab BY anzahl1.

DELETE ADJACENT DUPLICATES FROM htext1_tab COMPARING anzahl1.

CLEAR anz_dl2.

LOOP AT t.

WRITE t-kunnr TO anz_dl2.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

ENDLOOP.

SORT htext2_tab BY anzahl2.

DELETE ADJACENT DUPLICATES FROM htext2_tab COMPARING anzahl2.

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

LOOP AT htext1_tab INTO htext1.

CONDENSE htext1.

SKIP 2.

WRITE: / htext1.

ENDLOOP.

LOOP AT htext2_tab INTO htext2.

CONDENSE htext2.

SKIP 2.

WRITE:/ htext2.

ENDLOOP.

-


Please help, thank you!

0 Kudos

Hi,

'0000000' values for kunnr is appearing due to the field anz_dl1. as this field is numeric, if t1-kunnr is blank, it is considering as zeros. and once again u r passing this numeric field to htext1-anzahl1. Hence zeros are displayed.

Do you want to avoid the display of records with kunnr value zeros?

Try as follows:

CLEAR anz_dl1.

LOOP AT t1.

WRITE t1-kunnr TO anz_dl1.

If anz_dl1 is initial. (If anz_dl1 is zeros then continue with next record)

continue.

endif.

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

ENDLOOP.

SORT htext1_tab BY anzahl1.

DELETE ADJACENT DUPLICATES FROM htext1_tab COMPARING anzahl1.

CLEAR anz_dl2.

LOOP AT t.

WRITE t-kunnr TO anz_dl2.

If anz_dl2 is initial.

continue.

endif.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

ENDLOOP.

SORT htext2_tab BY anzahl2.

DELETE ADJACENT DUPLICATES FROM htext2_tab COMPARING anzahl2.

Former Member
0 Kudos

Hi

Why you see only single message is :

You are writing the message only once .

Your code is not written under any LOOP...ENDLOOP.

To get all the customer message build an internal table and write your message .

Hope it helps.

Thanks

Praveen

Former Member
0 Kudos

Hello

Do like this..

SORT T1 BY KUNNR .

DELETE ADJACENT DUPLICATES FROM t1 COMPARING kunnr .

Hope it helps.

Praveen

Former Member
0 Kudos

HI

WRITE anz_dl1 TO htext1-anzahl1.

APPEND htext1 TO htext1_tab.

.

WRITE anz_dl2 TO htext2-anzahl2.

APPEND htext2 TO htext2_tab.

Why u are using this code...any specific purpose ...

get rid of it .

Praveen