‎2007 Oct 02 3:00 AM
Experts,
Thanks for all the help in building the logic for me in the previous post...Now I have a internal table in which i have four columns: <b>Comp_code Doc_no Fis_year Ledger</b>
the internal table is filled with data like:
Comp_code Doc_no Fis_year Ledger
1001 7000000345 2007 L1
1001 7000000345 2007 L2
1001 7000000345 2007 L3
1001 7000000467 2007 L1
1001 7000000467 2007 L2
1001 7000000467 2007 L3Now i want the data to be present in internal table in this format:
Comp_code Doc_no Fis_year Ledger
1001 7000000345 2007 L1
L2
L3
2000 7000000467 2007 L1
L2
L3How can i do this...the code for the internal table with this data is as follows:
select bukrs belnr gjahr from BKPF into TABLE t_parked_docs where blart = 'SY'
and cpudt eq DATE_OF_ENTRY
and ppnam IS NOT NULL.
if sy-subrc = 0.
select bukrs belnr gjahr from BKPF into table t_posted_docs
for all entries in t_parked_docs
where BUKRS = t_parked_docs-v_comp_code and
BELNR = t_parked_docs-v_doc_no and
GJAHR = t_parked_docs-v_fiscal_year and
BSTAT = ''.
loop at t_posted_docs into wa_posted_docs.
select distinct rldnr from faglflexa into (wa_posted_docs-v_ledger)
where rbukrs = wa_posted_docs-v_comp_code
and docnr = wa_posted_docs-v_doc_no
and ryear = wa_posted_docs-v_fiscal_year.
APPEND wa_posted_docs to t_docs_posted_with_ledger.
endselect.
endloop.
Kindly give some suggestions.....
Cheers:
Sam
‎2007 Oct 02 3:40 AM
Hi,
Sorry..One small change..
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.
DATA: wa_tmp LIKE wa.
LOOP AT itab INTO wa.
*********** NEW CHANGE
* Move the values to a temporary structure.
wa_tmp = wa.
*********** NEW CHANGE.
* Move the ledger value to a temporary variable.
v_ledger = wa-ledger.
AT NEW fis_year.
* Move the values to final internal table.
APPEND wa_tmp TO itab_final. " Changed here..
* Process the next record.
CONTINUE.
ENDAT.
* Clear the structure and just move the ledger.
CLEAR: wa.
wa-ledger = v_ledger.
APPEND wa TO itab_final.
ENDLOOP.
* Now ITAB_FINAL will have all the values..
Thanks
Naren
‎2007 Oct 02 3:19 AM
Hey Sam,
Didnt this work??
loop at t_docs_posted_with_ledger into wa_posted_docs.
idx = sy-tabix.
wa_posted_docs1 = wa_posted_docs. " Temperory Work Area
if lv_belnr = wa_posted_docs-v_doc_no and sy-tabix ne 1.
clear: wa_posted_docs-v_comp_code, wa_posted_docs-v_doc_no, wa_posted_docs-v_fiscal_year.
modify t_docs_posted_with_ledger INDEX idx transporting wa_posted_docs.
endif.
lv_belnr = wa_posted_docs1-v_doc_no.
endloop.
‎2007 Oct 02 3:22 AM
No Sri...It did not...it is clearing all the values....just leaving the first value...let me try again....
and what is lv_belnr...?
Thanks
Sam
Message was edited by:
Sam williams
‎2007 Oct 02 3:26 AM
hmm...just tweak it a lil..it should work...may be you an debug and see...i am not sure abt the exact field names you have.
Basically the logic i tried is
Loop at itab into wa.
idx = sy-tabix.
*transfer entries into temperory wa.
wa1 = wa.
if lv_belnr = wa-belnr and idx ne 1.
clear wa, except the ledger field.
modify itab index idx transporting wa.
endif.
lv_belnr = wa1-belnr.
endloop.
You can play with it...
Sri
‎2007 Oct 02 3:28 AM
‎2007 Oct 02 3:39 AM
Hey sri,
Thanks for the reply buddy...
Let me tweak with it a little and then will let u know....
ANywayz really want to thak u for ur immediate replies....will definitely let u know...
Thanks
Sam
‎2007 Oct 02 3:23 AM
Hi,
Try this..
* create another internal table with the same structure as your data internal table.
*
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.
LOOP AT itab INTO wa.
* Move the ledger value to a temporary variable.
v_ledger = wa-ledger.
AT NEW fis_year.
* Move the values to final internal table.
APPEND wa TO itab_final.
* Process the next record.
CONTINUE.
ENDAT.
* Clear the structure and just move the ledger.
CLEAR: wa.
wa-ledger = v_ledger.
APPEND wa TO itab_final.
ENDLOOP.
* Now ITAB_FINAL will have all the values..
Thanks
Naren
‎2007 Oct 02 3:38 AM
Hi narendara,
thanks for the reply....it worls upto an extent but it doesnt get the ledger for the first time it runs...i mean it is able to get the ledger L2 and L3 but not L1 which is the first row....
Can i try somethin else...
Thanks
Sam
‎2007 Oct 02 3:40 AM
Hi,
Sorry..One small change..
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.
DATA: wa_tmp LIKE wa.
LOOP AT itab INTO wa.
*********** NEW CHANGE
* Move the values to a temporary structure.
wa_tmp = wa.
*********** NEW CHANGE.
* Move the ledger value to a temporary variable.
v_ledger = wa-ledger.
AT NEW fis_year.
* Move the values to final internal table.
APPEND wa_tmp TO itab_final. " Changed here..
* Process the next record.
CONTINUE.
ENDAT.
* Clear the structure and just move the ledger.
CLEAR: wa.
wa-ledger = v_ledger.
APPEND wa TO itab_final.
ENDLOOP.
* Now ITAB_FINAL will have all the values..
Thanks
Naren
‎2007 Oct 02 3:49 AM
Narendara,
It worked for me....i think it shud be fine now...thanks buddy....i am closing this thread for now but will always come back in case of queries....