‎2013 Nov 05 1:35 PM
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

‎2013 Nov 05 1:54 PM
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
‎2013 Nov 05 1:49 PM
I know that I can't see these. I suppose that many can't. Perhaps you could just talk us through the descriptions.
Neal
‎2013 Nov 05 1:56 PM
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
‎2013 Nov 05 1:54 PM
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
‎2013 Nov 05 2:15 PM
Hi Venkat,
Unfortunately it's not working. I get short dump GETWA_NOT_ASSIGNED.
Amine
‎2013 Nov 05 2:34 PM
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
‎2013 Nov 05 2:46 PM
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
‎2013 Nov 05 3:12 PM
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
‎2013 Nov 05 3:18 PM
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
‎2013 Nov 05 3:28 PM
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
‎2013 Nov 05 3:39 PM
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
‎2013 Nov 05 3:43 PM
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
‎2013 Nov 05 3:56 PM
‎2013 Nov 05 3:57 PM
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
‎2013 Nov 05 3:58 PM
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
‎2013 Nov 05 4:00 PM
‎2013 Nov 05 4:08 PM
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
‎2013 Nov 05 4:12 PM
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
‎2013 Nov 05 4:14 PM
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
‎2013 Nov 05 4:15 PM
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.
‎2013 Nov 05 4:19 PM
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
‎2013 Nov 05 4:37 PM
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
‎2013 Nov 05 4:58 PM
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
‎2013 Nov 05 5:04 PM
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
‎2013 Nov 05 5:04 PM
Thanks a lot Venkat. I will adapt the logic to my code and let you know.
Amine
‎2013 Nov 06 10:24 AM
‎2013 Nov 05 1:59 PM
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
‎2013 Nov 05 2:17 PM
Hi Vladimir,
I absolutly need this output. I think it possible but i have to find the way to do it
Amine
‎2013 Nov 05 2:24 PM
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?
‎2013 Nov 05 2:31 PM
The dispatch is like following:
Actif = Assets (first digit is A)
Passif = Liabilities (first digit P)
Thanks.
Amine
‎2013 Nov 05 2:38 PM
Ok, but is there a logic between them, like a100 goes with p100 or a320 goes with p320? What define one complete entry?
‎2013 Nov 05 2:49 PM
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.
‎2013 Nov 05 3:15 PM
‎2013 Nov 05 3:33 PM
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.
‎2013 Nov 06 10:57 AM
Hi,
Make it in simple way.
You can use MODIFY statement with transporting .