Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in code

Former Member
0 Likes
433

Hi,

As my requirement i write the logic.But when i go to debug mode iam facing some problem.

Condition :

1.If the document type is empty move the posting date(BUDAT) in the input structure to reporting date to the output structure.

1.1. 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” .

Logic :

data : begin of i_vbeln occurs 0,

vbeln like vbfa-vbeln,

end of i_vbeln.

data : wa_vbeln like i_vbeln.

data : ws_c_budat like bkpf-budat,

ws_c_matnr like vbap-matnr.

data : ws_lines type i.

Ranges : r_fkart for CE10001-fkart.

r_fkart-sign = 'I'.

r_fkart-option = 'EQ'.

r_fkart-low = 'B1'.

Append r_fkart.

r_fkart-sign = 'I'.

r_fkart-option = 'EQ'.

r_fkart-low = 'B1E'.

Append r_fkart. -


etc

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.

This part is working fine.

But the below part is not working.Means in the debug mode when cursor reach the elseif part it does not check the other conditions,directly it goes to last statemetn.(move-corresponding CE0_M200 to E_ITEM).

Conditions:

2. 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 .

2.1 Find the preceding doc (VBFA-VBELV) with the preceding document category(VBFA-VBTYP_V) M(invoice).

2.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.

2.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.

Logic :

ElseiF CE0_M200-FKART IN 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.

Problem is else if part is not working.Is there any changes in the code?Please suggest me.

Thanks & Regards,

sudhakar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
405

Hi,

In the Fist If Statement

IF NOT CE0_M200-FKART EQ r_fkart. - Are you sure this works since r_fkart is an internal table?

In the Else Part Did you check the value of CE0_M200-FKART in Debug Mode ? Also check if the value exists in r_fkart. If It exists, then it should execute the code.

Regards,

Shruthi

2 REPLIES 2
Read only

Former Member
0 Likes
406

Hi,

In the Fist If Statement

IF NOT CE0_M200-FKART EQ r_fkart. - Are you sure this works since r_fkart is an internal table?

In the Else Part Did you check the value of CE0_M200-FKART in Debug Mode ? Also check if the value exists in r_fkart. If It exists, then it should execute the code.

Regards,

Shruthi

Read only

0 Likes
405

Hi thanks for reply.It it working now.

Thanks,

sudha