2007 Sep 28 10:10 PM
Experts,
I have written a FM that takes current date and find out all the FI GL Documents that are parked and then check for documents that got posted...I mean parked docs that were posted....
I will attach the code here...I am returning the list of parked and posted docs as two tables...now i want to find the ledgers in which the parked documents got posted....so what shud i include in my code....Please suggest...
FUNCTION Z_FIGL_GL_PARK_TO_POST.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(V_CPUDT) TYPE CPUDT
*" TABLES
*" TB_PARKED STRUCTURE ZSFIGL_PARK_TO_POST
*" TB_POSTED STRUCTURE ZSFIGL_PARK_TO_POST
*"----
select BUKRS BELNR GJAHR from BKPF into TABLE tb_parked where BLART = 'SY'
AND CPUDT eq v_cpudt
AND PPNAM IS NOT NULL.
if sy-subrc = 0.
select BUKRS BELNR GJAHR from BKPF into table tb_posted
for all entries in tb_parked
where BUKRS = tb_parked-v_BUKRS AND
BELNR = tb_parked-v_BELNR AND
GJAHR = tb_parked-v_GJAHR AND
BSTAT = ''.
endif.
ENDFUNCTION.
Message was edited by:
Sam williams
2007 Sep 28 11:22 PM
I can get the ledger out of the FAGLFLEXA table but when i fill the TB_posted tablles it shud show the ledger also...
CC Doc NO Year Ledger
1001 7000000789 2007 I1
L1
L2
it has to be displayed like this...is it possible....
Thanks
Experts,
I have written a FM that takes current date and find out all the FI GL Documents that are parked and then check for documents that got posted...I mean parked docs that were posted....
I will attach the code here...I am returning the list of parked and posted docs as two tables...now i want to find the ledgers in which the parked documents got posted....so what shud i include in my code....Please suggest...
FUNCTION Z_FIGL_GL_PARK_TO_POST.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(V_CPUDT) TYPE CPUDT
*" TABLES
*" TB_PARKED STRUCTURE ZSFIGL_PARK_TO_POST
*" TB_POSTED STRUCTURE ZSFIGL_PARK_TO_POST
*"----
select BUKRS BELNR GJAHR from BKPF into TABLE tb_parked where BLART = 'SY'
AND CPUDT eq v_cpudt
AND PPNAM IS NOT NULL.
if sy-subrc = 0.
select BUKRS BELNR GJAHR from BKPF into table tb_posted
for all entries in tb_parked
where BUKRS = tb_parked-v_BUKRS AND
BELNR = tb_parked-v_BELNR AND
GJAHR = tb_parked-v_GJAHR AND
BSTAT = ''.
endif.
ENDFUNCTION.
Message was edited by:
Sam williams
2007 Sep 28 11:22 PM
I can get the ledger out of the FAGLFLEXA table but when i fill the TB_posted tablles it shud show the ledger also...
CC Doc NO Year Ledger
1001 7000000789 2007 I1
L1
L2
it has to be displayed like this...is it possible....
Thanks
2007 Sep 28 11:27 PM
Yes, it will be possible. You have the docnumber and company code and you can get the ledger from GLFLEXA table and MODIFY your TB_POSTED table.
Sri
2007 Sep 28 11:49 PM
Thanks for the reply Sri...how can i do it can u tell me....can u please show it to me ....
Thanks
2007 Oct 01 5:52 PM
HI gurus,
How can i do this...kindly help....I can get ledger data from FAGLFLEXA but how shud i modify the internal table so that ledger reflects there...i am trying to do this but each time the loop executes it replaces the ledger value with new one i want to keep each value...
I mean
CC Doc NO Year Ledger
-
1001 7000000789 2007 I1
L1
L2
-
I am trying this piece of code but it replaces the ledger value each time the loop executes...
loop at i_LEDGER into wa_LEDGER.
select distinct RLDNR from FAGLFLEXA into (wa_ledger-V_RLDNR) where RBUKRS = wa_LEDGER-v_RBUKRS and
DOCNR = wa_LEDGER-v_DOCNR and
RYEAR = wa_LEDGER-v_RYEAR.
Modify i_ledger FROM wa_ledger.
endselect.
endloop.
What shud i do to get the result....?
Please help...
Thanks
Sam
2007 Oct 01 6:29 PM
Sam - what release are you on? Table FAGLFLEXA doesn't exist in 4.7.
Do you mean GLFLEXA?
and how is I_LEDGER filled? You should post that portion of code.
Rob
Message was edited by:
Rob Burbank
2007 Oct 01 6:39 PM
Rob, I am on ECC 6.0...
Yaa. i think it is GLFLEXA in 4.7....
Thanks
Sam
2007 Oct 01 7:42 PM
2007 Oct 01 7:44 PM
2007 Oct 01 7:46 PM
oK...Let me send u the test code that i have written:
DATA: Begin of i_bkpf occurs 0,
v_bukrs LIKE BKPF-BUKRS,
v_BELNR LIKE BKPF-BELNR,
v_GJAHR LIKE BKPF-GJAHR.
DATA: End of i_bkpf.
DATA: Begin of i_ledger occurs 0,
v_rbukrs LIKE FAGLFLEXA-RBUKRS,
v_docnr LIKE FAGLFLEXA-DOCNR,
v_ryear LIKE FAGLFLEXA-RYEAR,
v_rldnr LIKE FAGLFLEXA-RLDNR.
DATA: End of i_ledger.
DATA: wa_ledger like i_ledger,
wa_bkpf like i_bkpf,
idx like sy-tabix.
select BUKRS BELNR GJAHR from BKPF into TABLE i_vbkpf where BLART = 'SY'
AND CPUDT eq p_cpudt
AND PPNAM IS NOT NULL.
if sy-subrc = 0.
select BUKRS BELNR GJAHR from BKPF into table i_LEDGER
for all entries in i_vbkpf
where BUKRS = i_vbkpf-v_BUKRS AND
BELNR = i_vbkpf-v_BELNR AND
GJAHR = i_vbkpf-v_GJAHR AND
BSTAT = ''.
endif.
loop at i_bkpf into wa_bkpf.
select rldnr from faglflexa into corresponding fields of i_ledger where
loop at i_LEDGER into wa_LEDGER.
select distinct RLDNR from FAGLFLEXA into (wa_ledger-V_RLDNR) where RBUKRS = wa_LEDGER-v_RBUKRS and
DOCNR = wa_LEDGER-v_DOCNR and
RYEAR = wa_LEDGER-v_RYEAR.
Modify i_ledger FROM wa_ledger.
endselect.
endloop.
Let me know what shud i do Rob
Thanks
Sam
2007 Oct 01 7:50 PM
Hey Sam,
Check this out...It should work for you....I have declared an internal table with i_faglflexa to avoid select...endselect and to use For All Entries to fetch all relevant document numbers..
TYPES: BEGIN OF i_faglflexa,
ryear TYPE faglflexa-ryear,
docnr TYPE faglflexa-docnr,
rldnr TYPE faglflexa-rldnr,
END OF i_faglflexa.
DATA: i_faglflexa TYPE STANDARD TABLE OF i_faglflexa.
DATA: wa_faglflexa LIKE LINE OF i_faglflexa.
DATA: t_tabix TYPE sy-tabix.
IF NOT i_ledger[] IS INITIAL.
SELECT DISTINCT ryear docnr rldnr FROM FAGLFLEXA
INTO TABLE i_faglflexa
FOR ALL ENTRIES IN i_ledger
WHERE ryear = i_ledger-ryear
AND docnr = i_ledger-docnr.
ENDIF.
LOOP AT i_ledger INTO wa_ledger.
t_tabix = sy-tabix.
READ TABLE i_faglflexa INTO wa_faglflexa
WITH KEY ryear = wa_ledger-ryear
docnr = wa_ledger-docnr.
IF sy-subrc EQ 0 .
wa_ledger-rldnr = wa_faglflexa-rldnr.
MODIFY i_ledger FROM wa_ledger INDEX t_tabix.
ENDIF.
CLEAR: wa_ledger, wa_faglflexa, t_tabix.
ENDLOOP.
Good Luck!!!
Regards,
Vivek
2007 Oct 01 7:54 PM
2007 Oct 01 7:55 PM
But this code is entirely different from the code you first posted in this thread. which code snippet is the problem?
Rob
2007 Oct 01 7:57 PM
May be you can do a JOIN on BKPF and GLFLEXA
Something like:
select bkpf~bukrs bkpf~belnr bkpf~gjahr glflexa~rldnr
into table i_ledger
from bkpf INNER JOIN glflexa
on bkpf~bulrs = glflexa~rbukrs AND
bkpf~belnr = glflexa~docnr AND
bkpf~gjahr = glflexa~ryear
FOR ALL ENTRIES IN i_vbkpf
where bkpf~BUKRS = i_vbkpf-v_BUKRS AND
bkpf~BELNR = i_vbkpf-v_BELNR AND
bkpf~GJAHR = i_vbkpf-v_GJAHR AND
bkpf~BSTAT = ''.Try it.
Sri
2007 Oct 01 7:57 PM
I take back...I didn't notice it..
> Where are you filling the i_ledger in the code??
2007 Oct 01 7:58 PM
Rob,
The first code that u see is a FM that i created from the current test code that i posted....
2007 Oct 01 8:02 PM
Sri, this code will work but it will give duplicate entries for ledger...a FI GL document gets posted in 3 ledgers I1 L1 L2 for debit and credit enties....
So this code will give: 6 entries back...
1001 7000000034 2007 I1
1001 7000000034 2007 I1
1001 7000000034 2007 L1
1001 7000000034 2007 L1
1001 7000000034 2007 L2
1001 7000000034 2007 L2
Thanks
2007 Oct 01 8:05 PM
So for each document, you want an entry in some table for each corresponding entry in the ledger table??
Rob
2007 Oct 01 8:06 PM
Then sort and Delete duplicates...
Wont it solve your purpose??
Sri
2007 Oct 01 8:09 PM
It will...how shud i do that Sri....can u please tell me....
2007 Oct 01 8:10 PM
Anyway, see if this helps:
DATA: BEGIN OF i_vbkpf OCCURS 0,
v_bukrs LIKE bkpf-bukrs,
v_belnr LIKE bkpf-belnr,
v_gjahr LIKE bkpf-gjahr.
DATA: END OF i_vbkpf.
DATA: BEGIN OF i_ledger OCCURS 0,
v_rbukrs LIKE glflexa-rbukrs,
v_docnr LIKE glflexa-docnr,
v_ryear LIKE glflexa-ryear,
v_rldnr LIKE glflexa-rldnr.
DATA: END OF i_ledger.
DATA: wa_ledger LIKE i_ledger,
wa_bkpf LIKE i_vbkpf,
idx LIKE sy-tabix.
DATA: BEGIN OF final_tab OCCURS 0.
INCLUDE STRUCTURE i_ledger.
DATA: END OF final_tab.
SELECT bukrs belnr gjahr
FROM bkpf
INTO TABLE i_vbkpf WHERE blart = 'SY'
AND cpudt EQ p_cpudt
AND ppnam IS NOT NULL.
IF sy-subrc = 0.
SELECT bukrs belnr gjahr
FROM bkpf INTO TABLE i_ledger
FOR ALL ENTRIES IN i_vbkpf
WHERE bukrs = i_vbkpf-v_bukrs AND
belnr = i_vbkpf-v_belnr AND
gjahr = i_vbkpf-v_gjahr AND
bstat = ''.
ENDIF.
LOOP AT i_ledger INTO wa_ledger.
SELECT DISTINCT rldnr FROM faglflexa INTO (wa_ledger-v_rldnr) WHERE
rbukrs = wa_ledger-v_rbukrs AND
docnr = wa_ledger-v_docnr AND
ryear = wa_ledger-v_ryear.
APPEND wa_ledger TO final_tab.
ENDSELECT.
ENDLOOP.Rob
2007 Oct 01 8:13 PM
Once you get the entries into i_ledger from the JOIN statement,
SORT i_ledger BY v_bukrs v_belnr v_gjahr v_rldnr.
DELETE ADJACENT DUPLICATES FROM i_ledger COMPARING v_bukrs v_belnr v_gjahr v_rldnr.
This should work.
Sri
2007 Oct 01 8:13 PM
Hey Sam,
Do this to delete duplicates...
SORT i_ledger.
DELETE ADJACENT DUPLICATES FROM i_ledger.
Also, did you try the code, I posted in my first reply to this thread?
Regards,
Vivek
2007 Oct 01 8:21 PM
Yes Vivek...I did....it doeant work properly....it replaces all the values in the I_ledger table with only the first row ....it duplicates the first row in the entire table....
I am still trying...
But actually my main requirement is that:
<b>1001 70000000345 2007 I1
L1
L2</b>
I mean the company code doc number and year shu just come once and then ledgers...I1 L1 L2 in three different lines....
I am trying to do that if possible...
Thanks a lot...
Sam
2007 Oct 01 8:24 PM
2007 Oct 01 8:25 PM
Once you delete the duplicates, i think you should be getting what you wanted???
Let me know if you need anything else.
Sri
2007 Oct 01 8:26 PM
U r right Rob....its working....but it gets in this format:
1001 7000000345 2007 I1
1001 7000000345 2007 L1
1001 7000000345 2007 L2
Can we somehow clear the last two lines but leave the ledgers so that 1001 700000345 2007 just appears once...is it possible...?
Thanks Buddy
Sam
2007 Oct 01 8:27 PM
2007 Oct 01 8:39 PM
If you want to delete the 3 fields for the rest of the entries, may be try something like this:
loop at i_ledger into wa_ledger.
wa_ledger_temp = wa_ledger. " Temperory Work Area
if lv_belnr = wa_ledger-belnr and sy-tabix ne 1.
clear: wa_ledger-bukrs, wa_ledger-belnr, wa_ledger-gjahr.
modify i_ledger transporting wa_ledger.
endif.
lv_belnr = wa_ledger_temp-belnr.
endloop.
Sri
2007 Oct 02 1:10 AM
Hey Sri,
It doesnt work....i am still getting 3 rows with Compoany code document number fiscal year repeating...can i try something else...
Thanks Sam
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |