07-26-2006 4:07 PM
Hello,
Can someone please help write some basic code for a Basis guy with limited ABAP knowledge?
Should be some easy points for an experienced ABAPer!
-
I have identicaly structured internal tables I_A and I_B and I_C which have already been filled by function models I called.
How will I code the following?:
I want to read all the data of I_A into a new internal table I_MASTER (structured the same as I_A,I_B and I_C).
Then I want to read I_B and:
1)Update I_MASTER with NEW records
2)Update existing records if the value of field MYFIELD in I_B is smaller than the value of MYFIELD in I_MASTER.
Then I want to read I_C and:
1)Update I_MASTER with NEW records
2)Update existing records if the value of field MYFIELD in I_C is smaller than the value of MYFIELD in I_MASTER.
Let me know if I can provide anymore information.
Thanks in advance for you help!
Adriaan
Message was edited by: Adriaan
Message was edited by: Adriaan
07-26-2006 4:09 PM
Look to t-code ABAPDOCU. It contains many good examples to assist you.
07-26-2006 4:09 PM
Look to t-code ABAPDOCU. It contains many good examples to assist you.
07-26-2006 4:16 PM
Hi Adriaan ,
I want to read all the data of I_A into a new internal table I_MASTER (structured the same as I_A,I_B and I_C).
<b>i_master[] = i_a[] .</b>
loop at i_b .
read table i_master with key myfiled < i_b-myfield .
if sy-subrc = 0 .
append i_master from i_b .
endif.
endloop.
loop at i_c .
read table i_master with key myfiled < i_c-myfield .
if sy-subrc = 0 .
append i_master from i_c .
endif.
endloop.
Let me know if this helped .
Regards,
Varun .
Message was edited by: varun sonu
07-26-2006 4:29 PM
Varun,
Thank you very much!
This is sort of what I am looking for.
Just a question:
Will this code also add records from I_B and I_C not existing yet in I_MASTER to I_MASTER?
07-26-2006 4:35 PM
07-26-2006 8:23 PM
Hi Adriaan. You could try this:
I_MASTER [] = I_A [].
loop at I_B.
found = 'N'.
loop at I_MASTER where KEY = I_B-KEY.
if I_B-MYFIELD < I_MASTER-MYFIELD.
I_MASTER-MYFIELD = I_B-MYFIELD.
endif.
found = 'Y'.
endloop.
if found = 'N'.
append I_B to I_MASTER.
endif.
endloop.
loop at I_C.
found = 'N'.
loop at I_MASTER where KEY = I_C-KEY.
if I_C-MYFIELD < I_MASTER-MYFIELD.
I_MASTER-MYFIELD = I_C-MYFIELD.
endif.
found = 'Y'.
endloop.
if found = 'N'.
append I_C to I_MASTER.
endif.
endloop.
I hope this helps.
- April King