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

Output issue internal table

Former Member
0 Likes
5,051

Hello experts,

I have an issue with an internal table after the followinf loop:

CLEAR wa_bilan.

   LOOP AT wt_data ASSIGNING <fs_data>.

     IF <fs_data>-y_rmaccnt(1) = 'A'.

       wa_bilan-actif = <fs_data>-y_rmaccnt.

       wa_bilan-mta = <fs_data>-deb_cre_lc.

     ELSEIF <fs_data>-y_rmaccnt(1) = 'P'.

       wa_bilan-passif = <fs_data>-y_rmaccnt.

       wa_bilan-mtp = <fs_data>-deb_cre_lc.

     ENDIF.

     APPEND wa_bilan  TO wt_bilan.

     CLEAR wa_bilan .

ENDLOOP.

In debug mode, my internal table looks as following:

http://www.hostingpics.net/viewer.php?id=717481CopiedeSanstitre.png

How can i do to display it as follwing (all in the same line):

http://www.hostingpics.net/viewer.php?id=703578Sanstitre.png

Thanks.

Amine

PS : Sorry i can't display directly the pictures on my question

http://www.hostingpics.net/viewer.php?id=717481CopiedeSanstitre.png

1 ACCEPTED SOLUTION
Read only

venkat_aileni
Contributor
0 Likes
5,008

Hi-

Try below logic:

* Assuming it_final is your final internal table.

LOOP AT it_final ASSIGNING <wa_final>.

   CLEAR <wa_final_temp>.

   IF <wa_final>-passif IS NOT INITIAL AND

      <wa_final>-mtp    IS NOT INITIAL.

     <wa_final_temp> = <wa_final>.

     CLEAR: <wa_final_temp>-actif,

            <wa_final_temp>-mta.

     APPEND <wa_final_temp> TO it_final_temp.

     CLEAR: <wa_final>-passif,

            <wa_final>-mtp.

   ENDIF.

ENDLOOP.

APPEND LINES OF it_final_temp TO it_final.

-Venkat

34 REPLIES 34
Read only

Former Member
0 Likes
5,008

I know that I can't see these.  I suppose that many can't.  Perhaps you could just talk us through the descriptions.

Neal

Read only

0 Likes
5,008

Hi Neal,

The display is as following:

ACTIF

MTA

PASSIF

MTP

A100

10

A200

15

A300

20

P100

10

P200

28

P300

24

I would like it as following:

ACTIF

MTA

PASSIF

MTP

A100

10

P100

10

A200

15

P200

28

A300

20

P300

24

Please, if you want to see the picture just copy/past the url in your browser. I have an issue with my computer this is why I couldn’t upload the pictures.

Thanks.

Amine

Read only

venkat_aileni
Contributor
0 Likes
5,009

Hi-

Try below logic:

* Assuming it_final is your final internal table.

LOOP AT it_final ASSIGNING <wa_final>.

   CLEAR <wa_final_temp>.

   IF <wa_final>-passif IS NOT INITIAL AND

      <wa_final>-mtp    IS NOT INITIAL.

     <wa_final_temp> = <wa_final>.

     CLEAR: <wa_final_temp>-actif,

            <wa_final_temp>-mta.

     APPEND <wa_final_temp> TO it_final_temp.

     CLEAR: <wa_final>-passif,

            <wa_final>-mtp.

   ENDIF.

ENDLOOP.

APPEND LINES OF it_final_temp TO it_final.

-Venkat

Read only

0 Likes
5,008

Hi Venkat,

Unfortunately it's not working. I get short dump GETWA_NOT_ASSIGNED.

Amine

Read only

0 Likes
5,008

Hi-

Check below sample code:

TYPES: BEGIN OF t_final,

        col1 TYPE i,

        col2 TYPE i,

        col3 TYPE i,

        END OF t_final.

DATA: it_final TYPE STANDARD TABLE OF t_final,

       it_final_temp TYPE STANDARD TABLE OF t_final,

       wa_final TYPE t_final,

       wa_final_temp TYPE t_final.

CLEAR: wa_final.

wa_final-col1 = 1.

wa_final-col2 = 1.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col1 = 2.

wa_final-col2 = 2.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col3 = 1.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col3 = 2.

APPEND wa_final TO it_final.

WRITE: 'Before Aligning'.

ULINE.

LOOP AT it_final INTO wa_final.

   WRITE: / wa_final-col1, wa_final-col2, wa_final-col3.

ENDLOOP.

it_final_temp[] = it_final[].

DELETE it_final_temp WHERE col3 IS INITIAL.

DELETE it_final WHERE col3 IS NOT INITIAL.

LOOP AT it_final INTO wa_final.

CLEAR: wa_final_temp.

READ TABLE it_final_temp INTO wa_final_temp INDEX sy-tabix.

IF sy-subrc = 0.

   wa_final-col3 = wa_final_temp-col3.

   MODIFY it_final FROM wa_final INDEX sy-tabix.

ENDIF.

ENDLOOP.

ULINE.

WRITE: / 'After Aligning'.

ULINE.

LOOP AT it_final INTO wa_final.

   WRITE: / wa_final-col1, wa_final-col2, wa_final-col3.

ENDLOOP.

Output:


-Venkat

Read only

0 Likes
5,008

Hi-

I think now you can make required modifications in your code.

something like below:

LOOP AT it_final INTO wa_final.

CLEAR: wa_final_temp.

CONCATINATE: 'P' wa_final-ACTIF+1(3) INTO lv_key.

CONDENSE lv_key.

READ TABLE it_final_temp INTO wa_final_temp WITH KEY passif = lv_key.

IF sy-subrc = 0.

   wa_final-col3 = wa_final_temp-col3.

   MODIFY it_final FROM wa_final INDEX sy-tabix.

ENDIF.

ENDLOOP.

Hope it's clear now...

-Venkat

Read only

0 Likes
5,008

Venkat,

Thanks a lot for your very helpful answers.

I tried the following code based on your explanations:

LOOP AT wt_bilan INTO wa_bilan.

     CLEAR: wa_bilan_temp.

*CONCATeNATE: 'P' wa_bilan-ACTIF+1(3) INTO lv_key.

*CONDENSE lv_key.

     READ TABLE wt_bilan_temp INTO wa_bilan_temp INDEX sy-tabix.

     IF sy-subrc = 0.

       wa_bilan-passif = wa_bilan_temp-passif.

       wa_bilan-mtp = wa_bilan_temp-mtp.

       MODIFY wt_bilan FROM wa_bilan INDEX sy-tabix.

     ENDIF.

   ENDLOOP.

It looks to work fine. But i didn't get the :

*CONCATeNATE: 'P' wa_bilan-ACTIF+1(3) INTO lv_key.

*CONDENSE lv_key.

The code works whithout those lines, could you explain please?

Thanks.

Amine

Read only

0 Likes
5,008

Hi Amine

As everyone is asking for the link between two fields without it it wont work. Because you wont know which pasif to assign which activ

nabheet

Read only

0 Likes
5,008

Hi-

I have written those statements assuming:

ACTIF

MTA

PASSIF

MTP

A100

10

A200

15

A300

20

P100

10

P200

28

P300

24

say if value of field ACTIF is 'A100' then value of PASSIF should be :

PASSIF = 1st character (P) + last 3 characters of field ACTIF.

                 P + 100.

Hope its clear now.

Let me know if you need more clarification.

-Venkat

Read only

0 Likes
5,008

Ok, but it was only an example.

Thee is no link between Actif and Passif

Data could be as this:

ACTIF

MTA

PASSIF

MTP

A100

10

A200

15

A300

20

P999

10

P4444

28




Thanks.

Amine

Read only

0 Likes
5,008

OK, thanks for your clarification.

Question:

Does first value of PASSIF needs to be added to the first row(not heading line) of below table and second value of PASSIF to 2nd line so on? If this is the case use my first logic else there should be some link to how to assign values of PASSIF and MTP to the initial rows.

ACTIF

MTA

PASSIF

MTP

A100

10

A200

15

A300

20

P999

10

P4444

28




Kindly confirm.

-Venkat

Read only

0 Likes
5,008

Then on what basis you will link???

Read only

0 Likes
5,008

Yes i confirm Venkat. As i mentieoned in my previous answer here the code that i am using:

*  DELETE wt_bilan_temp WHERE passif IS INITIAL AND mtp IS INITIAL. "PASSIF

*  DELETE wt_bilan WHERE actif IS INITIAL AND mta IS INITIAL. "ACTIF

*  LOOP AT wt_bilan INTO wa_bilan.

*    CLEAR: wa_bilan_temp.

*    READ TABLE wt_bilan_temp INTO wa_bilan_temp INDEX sy-tabix.

*    IF sy-subrc = 0.

*      wa_bilan-passif = wa_bilan_temp-passif.

*      wa_bilan-mtp = wa_bilan_temp-mtp.

*      MODIFY wt_bilan FROM wa_bilan INDEX sy-tabix.

*    ENDIF.

*  ENDLOOP.


But i have an issue. The code is working fine only if i have more records in Actif then Passif.

If i have more records in passif the above code doesen't work anymore.

Amine

Read only

0 Likes
5,008

I would suggest starting with them in two seperate itabs.  Then loop through Itab1 and read itab2 with the index of itab1.  Then transfer the values from filled columns in itab 2 into itab 1.

Neal

Read only

0 Likes
5,008

There is no link nabheet. It's only an output format matter

Read only

0 Likes
5,008

Hi-

My logic will work something like this:

Say you have total table entries like: 25

Out of which:

10 are for ACTIF.

15 records for PASSIF.

After executing my logic:

First 10 records of PASSIF will be assigned to 10 records of ACTIF and the remaining 5 will be lost because we are adding values based on ACTIF and not based on PASSIF.

Thanks and let me know if you need more clarification.

-Venkat

Message was edited by: Venkat Aileni

Read only

0 Likes
5,008

This exaclty what happens Venkat.

But i don't want to lost any data. In your case, at the end i would like 10 in Actif and 25 in passif.

Thanks.

Amine

Read only

0 Likes
5,008

And of course if i have 30 Actif and 10 Passif.

I expect at the end 30 in Actif and 10 in Passif.

Thanks a lot.

Amine

Read only

0 Likes
5,008

So start with itab1 as

ACTIF

MTA

PASSIF

MTP

A100

10

A200

15

A300

20

and

itab2 as

P999

10

P4444

28


Loop at itab1 into wa1

  t_tabix = sy-tabix

  read itab2 into wa2 index t_tabix

move wa2-passif to wa1-passif

and so on.

Neal

PS: the logic will be dependent on reading the shorter table into the longer.

Read only

0 Likes
5,008

Hi-

I think you are clear with my previous reply.

Total Records: 25

Actif - 10

Passif - 15

Now my logic will result in assigning 1st line of ACTIF to 1st line of PASSIF and it continues till 10. After this 5 records of PASSIF were missing, how you would like to assign these 5 records? like empty fields for ACTIF and MTA and to just update PASSIF and MTP values? Or how would you like to fill these 5 rows to your final internal table.

ACTIF

MTA

PASSIF

MTP

11

12

13

14

15

-Venkat

Read only

0 Likes
5,008

Hi Venkat,

First case:


Actif - 4

Passif - 2

The expected table:

ACTIF

MTA

PASSIF

MTP

A223

10

P12344

1000

A380

2000

P1000

300

A320

40

A220

20

Second case:


Actif - 3

Passif – 5

ACTIF

MTA

PASSIF

MTP

A223

10

P12344

1000

A380

2000

P1000

300

A320

40

P4453

3299

P9974

3432

P77466

3000

Thanks.

Amine

Read only

0 Likes
5,008

Hi-

Thanks for your clarification .

Refer below code this should solve your problem.

TYPES: BEGIN OF t_final,

        col1 TYPE i,

        col2 TYPE i,

        col3 TYPE i,

        END OF t_final.

DATA: it_final TYPE STANDARD TABLE OF t_final,

       it_final_temp TYPE STANDARD TABLE OF t_final,

       wa_final TYPE t_final,

       wa_final_temp TYPE t_final.

DATA: lv_cnt TYPE i,

       lv_tabix TYPE sy-tabix.

CLEAR: wa_final.

wa_final-col1 = 1.

wa_final-col2 = 1.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col1 = 2.

wa_final-col2 = 2.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col1 = 3.

wa_final-col2 = 3.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col1 = 4.

wa_final-col2 = 4.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col3 = 1.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col3 = 2.

APPEND wa_final TO it_final.

CLEAR: wa_final.

wa_final-col3 = 3.

APPEND wa_final TO it_final.

WRITE: 'Before Aligning'.

ULINE.

LOOP AT it_final INTO wa_final.

   WRITE: / wa_final-col1, wa_final-col2, wa_final-col3.

ENDLOOP.

it_final_temp[] = it_final[].

DELETE it_final_temp WHERE col3 IS INITIAL.

DELETE it_final WHERE col3 IS NOT INITIAL.

lv_cnt = lines( it_final_temp ).

LOOP AT it_final INTO wa_final.

   CLEAR: wa_final_temp.

   lv_tabix = sy-tabix.

   IF lv_cnt GE lv_tabix.

     READ TABLE it_final_temp INTO wa_final_temp INDEX 1.

     IF sy-subrc = 0.

       wa_final-col3 = wa_final_temp-col3.

       MODIFY it_final FROM wa_final INDEX lv_tabix.

       DELETE it_final_temp INDEX 1.

     ENDIF.

   ENDIF.

ENDLOOP.

IF it_final_temp[] IS NOT INITIAL.

   APPEND LINES OF it_final_temp TO it_final.

ENDIF.

ULINE.

WRITE: / 'After Aligning'.

ULINE.

LOOP AT it_final INTO wa_final.

   WRITE: / wa_final-col1, wa_final-col2, wa_final-col3.

ENDLOOP.

-Venkat

Read only

0 Likes
5,008

CLEAR wa_bilan. 

   LOOP AT wt_data ASSIGNING <fs_data>. 

     IF <fs_data>-y_rmaccnt(1) = 'A'. 

       wa_bilan-actif = <fs_data>-y_rmaccnt. 

       wa_bilan-mta = <fs_data>-deb_cre_lc. 

Append wa_bilan to lt_milan

     ELSEIF <fs_data>-y_rmaccnt(1) = 'P'. 

       wa_bilan-passif = <fs_data>-y_rmaccnt. 

       wa_bilan-mtp = <fs_data>-

      If li_milan is initial

        Appen wa_bilan to lt_bilan

      Else.

While lv_flag ne X-------> copy this logic ACTIF also and just change field to actif

Read table lt_milan into wa_milan1 index sy-tabix.

If Sy-subrc eq 0

If wa_milan1-paasif is initial.

Modify lt_plan index sy-tabix from wa_milan transporting passif etc..

Lv_flag = X

Else continue.

Endif.

Else.

Append wa_milan to lt_milan

Lv_flag = X.

Endif.

Endwhile.

Endif

Endif.

ENDLOOP. 

The above mention logic will work for both case.

Sorry for formatting using mobile device

Read only

0 Likes
5,008

Thanks a lot Venkat. I will adapt the logic to my code and let you know.

Amine

Read only

0 Likes
5,008

Thanks a lot Venkat for your help.

Amine

Read only

vladimir_erakovic
Contributor
0 Likes
5,008

Hi Amine,

I think it's not possible to accomplish that with that way. Why don't use just one column for ACTIF and PASSIF both and other for MTA/MTP value? Then you would get something like this:

ACT_PAS     MTA_MTP

A3500          322780213

A3900             121378 -

P1010               12303 -

P1200              1369044

Regards

Read only

0 Likes
5,008

Hi Vladimir,

I absolutly need this output. I think it possible but i have to find the way to do it

Amine

Read only

0 Likes
5,008

Ok let me think. Is there any connection between ACTIF and PASSIF? How to know in which row to add which value? Or it doesn't matter, they just going one after another?

Read only

0 Likes
5,008

The dispatch is like following:

Actif = Assets (first digit is A)

Passif = Liabilities (first digit P)

Thanks.

Amine

Read only

0 Likes
5,008

Ok, but is there a logic between them, like a100 goes with p100 or a320 goes with p320? What define one complete entry?

Read only

Former Member
0 Likes
5,008

Hi,

Must be required linkage between ACTIF and PASSIF. 

You need to fill your internal table with the below condition.

A (100 ) = P(100).

A(200) = P(200)

A(300) = P(300).

A Acitf

P- Passif.

Which database tables are you using to extract the data.

Thanks,

Kiran.

Read only

0 Likes
5,008

Is collect statement an option?

Read only

Former Member
0 Likes
5,008

Hi,

Try with the below temporary code.

TYPES: BEGIN OF it_test ,
       actif(5),
       passif(5),
       mta(3),
       mtp(3),
       END OF it_test.
.
DATA : it_final TYPE STANDARD TABLE OF it_test WITH HEADER LINE.
DATA :  it_temp TYPE STANDARD TABLE OF it_test WITH HEADER LINE.

it_final-actif = 'A100'.
it_final-mta  = '10'.
APPEND it_final.
CLEAR it_final.
it_final-actif = 'A200'.
it_final-mta  = '15'.
APPEND it_final.
CLEAR it_final.
it_final-actif = 'A300'.
it_final-mta  = '30'.
APPEND it_final.
CLEAR it_final.



it_final-passif = 'P100'.
it_final-mtp  = '10'.
APPEND it_final.
CLEAR it_final.
it_final-passif = 'P200'.
it_final-mtp  = '28'.
APPEND it_final.
CLEAR it_final.
it_final-passif = 'P300'.
it_final-mtp  = '24'.

APPEND it_final.
CLEAR it_final.

it_temp[] = it_final[].

DELETE it_final[] WHERE passif IS NOT INITIAL AND
                         actif IS INITIAL.

LOOP AT it_final.
   READ TABLE it_temp WITH KEY passif+1(3) = it_final-actif+1(3).
   IF sy-subrc = 0.
     it_final-passif = it_temp-passif.
     it_final-mtp = it_temp-mtp.
     MODIFY it_final TRANSPORTING passif mtp.
   ENDIF.
   CLEAR it_final.
ENDLOOP.

Thanks,

Kiran.

Read only

Former Member
0 Likes
5,008

Hi,

Make it in simple way.

You can use MODIFY statement with transporting .