‎2007 Jul 29 8:01 AM
Hi,
I write the logic for my requirement for moving the posting date.
Logic is :
CASE I_ERKRS.
WHEN 'M200'.
MOVE-CORRESPONDING I_ITEM to CE0_M200.
IF NOT CE0_M200-fkart is initial.
IF NOT CE0_M200-FKART eq r_fkart.
CE0_M200-WWRPT = CE0_M200-BUDAT.
ElseiF CE0_M200-FKART eq r_fkart.
SELECT VBELn FROM VBFA into table i_vbeln
where vbelv = CE0_M200-kaufn
and VBTYP_V eq 'M'.
if sy-subrc = 0.
Describe table i_vbeln lines ws_lines .
If ws_lines = 1 .
Read table i_vbeln into wa_vbeln index 1 .
select single budat into ws_budat
from bkpf where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.
CE0_M200-WWRPT = ws_budat .
Elseif ws_lines >= 1.
loop at i_vbeln into wa_vbeln.
select single matnr from vbrp into ws_c_matnr
where vbeln = wa_vbeln-vbeln
and matnr = CE0_M200-artnr.
if sy-subrc = 0.
select single budat into ws_budat
from bkpf
where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.
CE0_M200-WWRPT = ws_budat .
exit.
ENDIF.
endloop.
ENDIF.
ENDIF.
ENDIF.
endif.
move-corresponding CE0_M200 to E_item.
ENDCASE.
First part is working fine.Means
IF NOT CE0_M200-fkart is initial.
IF NOT CE0_M200-FKART eq r_fkart.
CE0_M200-WWRPT = CE0_M200-BUDAT.
<b>When cursor comes to Elseif part</b>
ElseiF CE0_M200-FKART eq r_fkart.
it does not check any other conditions,directly cursor go to the move-corresponding CE0_M200 to E_item step.
What happend?Is there any wrong in my logic?Please give me ur suggestions?
Thanks & Regards,
sudhakar
‎2007 Jul 29 8:05 AM
Hi
I hope that R_FKART is a RANGE field
the you should use IN parameter instead of EQ operation like
IF NOT CE0_M200-FKART <b>IN</b> r_fkart and
IF CE0_M200-FKART <b>IN</b> r_fkart
change this and see again
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Jul 29 8:10 AM
Yes, I have changed.
But in ur case posting date(BUDAT) is not moving to the reportind date(WWRPT).
But when i write the EQ,posting date is moving to reportin date.
And also
second part is not working .From
ElseiF CE0_M200-FKART eq r_fkart.
Thanks-
sudhar
‎2007 Jul 29 8:16 AM
Hi,
CASE I_ERKRS.
WHEN 'M200'.
MOVE-CORRESPONDING I_ITEM to CE0_M200.
IF NOT CE0_M200-FKART eq r_fkart and NOT CE0_M200-fkart is initial.
CE0_M200-WWRPT = CE0_M200-BUDAT.
SELECT VBELn FROM VBFA into table i_vbeln
where vbelv = CE0_M200-kaufn
and VBTYP_V eq 'M'.
if sy-subrc = 0.
Describe table i_vbeln lines ws_lines .
If ws_lines = 1 .
Read table i_vbeln into wa_vbeln index 1 .
select single budat into ws_budat
from bkpf where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.
CE0_M200-WWRPT = ws_budat .
endif.
if ws_lines >= 1.
loop at i_vbeln into wa_vbeln.
select single matnr from vbrp into ws_c_matnr
where vbeln = wa_vbeln-vbeln
and matnr = CE0_M200-artnr.
if sy-subrc = 0.
select single budat into ws_budat
from bkpf
where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.
CE0_M200-WWRPT = ws_budat .
exit.
ENDIF.
endloop.
ENDIF.
endif.
endif.
move-corresponding CE0_M200 to E_item.
ENDCASE.
Please use pretty printer option once you activate the code it will avoid confusion of if and endiff
Points are always welcome
aRs
‎2007 Jul 29 8:29 AM
‎2007 Jul 29 8:38 AM
Hi,
Please check the Requirement for logic.
1. check whether Billing document type(FKART) is empty or not .
1.1. If the document type is empty move the posting date(BUDAT) in the
input structure to reporting date to the output structure.
1.2. If the document type(FKART) of the input structure is not empty and
does not contains any of the following doocument types B1, B1E,
B2, B2E, B3, B3E, B4, BK1, BK3, FXG, G2, G2S, JGL, RE, VLG2,
BM1, BM3, FXL, JLL or L2 .
1.2.1.Check that billing document category (VBRK_VBTYP) is not
available in the input structure then move the posting date
(BUDAT) in the input structure to reporting date to the output
structure.
1.3. if the document type(FKART) of the input structure is not empty and
contains any one the following document type B1, B1E, B2, B2E, B3,
B3E, B4, BK1, BK3, FXG,G2, G2S, JGL, RE, VLG2, BM1, BM3, FXL,
JLL or L2 .
1.3.1.Check that billing document category (VBRK_VBTYP) is not
available in the input structure.
1.3.1.1. Find the preceding doc (VBFA-VBELV) with the preceding
document category(VBFA-VBTYP_V) M(invoice).
1.3.1.2. If only one preceding document with category M found, then
pass VBRK as the referenceprocedure(BKPF - AWTYP)
and the billing (invoice) document number found above as
the reference key(BKPF AWKEY) to the input structure
and pass the posting date(BKPF BUDAT) to the reporting
date (WWWRPT) to the output structure.
1.3.1.3 If there are multiple preceding document with category M
(invoice) are found,use the material number in the credit
memo to find the invoice with matched material number.If
the first invoice found with the matched material number will
be used to derive the reporting date.
This is my requirement.Is it correct my logic.Any body give me suggestions.
Thanks,
sudhakar
‎2007 Jul 29 9:19 AM
Hi,
I have tried ur coding.This code also working for first condition.
IF NOT CE0_M200-FKART eq r_fkart and NOT CE0_M200-fkart is initial.
CE0_M200-WWRPT = CE0_M200-BUDAT.
But second condition ElseiF CE0_M200-FKART IN r_fkart is not working.
if the document type(FKART) of the input structure is not empty and contains any one the following document type B1, B1E, B2, B2E, B3, B3E, B4, BK1, BK3, FXG,G2, G2S, JGL, RE, VLG2, BM1, BM3, FXL, JLL or L2 .
-sudhakar