cancel
Showing results for 
Search instead for 
Did you mean: 

Data source Enhancemnt

Former Member
0 Kudos

HI ,

I want to do data source enhancemnt as per the followint logic

IF xvbak-vbtyp = 'K' OR xvbak-vbtyp = 'H').

SELECT vbeln posnn rfmng vbtyp_n FROM vbfa

INTO TABLE xvbfa

WHERE vbelv = xvbak-vbeln

AND posnv = xvbap-posnr

LOOP AT xvbfa.

CASE xvbfa-vbtyp_n.

WHEN 'O'.

doccnt = doccnt + 1.

WHEN 'S'.

canccnt = canccnt + 1.

ENDCASE.

ENDLOOP.

IF doccnt > canccnt.

get the Amount and quantity .

<b>

i wrote the following logic in user exit for 2lis_11_vaitm</b>

IF ( S_MC11VA0ITM-VBTYP = 'K' OR S_MC11VA0ITM-VBTYP = 'H' ).

CLEAR: DOCCNT, CANCCNT, NOCOUNT.

CLEAR I_VBFA.

CLEAR L_VBELN.

SELECT SINGLE VBELN FROM VBAK INTO L_VBELN

WHERE VBELN = S_MC11VA0ITM-VBELN .

SELECT VBELN POSNN RFMNG VBTYP_N FROM VBFA INTO TABLE I_VBFA WHERE VBELV = L_VBELN AND POSNV = S_MC11VA0ITM-POSNR .

LOOP AT I_VBFA.

CASE I_VBFA-VBTYP_N.

WHEN 'O'.

DOCCNT = DOCCNT + 1.

WHEN 'S'.

CANCCNT = CANCCNT + 1.

WHEN OTHERS.

NOCOUNT = NOCOUNT + 1 .

ENDCASE.

ENDLOOP.

IF ( DOCCNT > CANCCNT ) .

S_MC11VA0ITM-ZZCRDBAMT = S_MC11VA0ITM-NETWR.

S_MC11VA0ITM-ZZCRDBQTY = S_MC11VA0ITM-KWMENG.

ENDIF.

ENDIF.

IS THIS logic correct.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

HI Nagesh and A.H.P

Thanks very much for ur help , i am awarding points for both of u .

Regards,

Ogili Reddy

edwin_harpino
Active Contributor
0 Kudos

dear Abi,

the logic seems correct, but i think you won't need the line bold

select vbeln ... where vblen = S_MC11VA0ITM-VBELN

will just get same value as S_MC11VA0ITM-VBELN

hope this helps.

...

CLEAR L_VBELN.

<b>SELECT SINGLE VBELN FROM VBAK INTO L_VBELN

WHERE VBELN = S_MC11VA0ITM-VBELN .</b>

SELECT VBELN POSNN RFMNG VBTYP_N FROM VBFA INTO TABLE I_VBFA WHERE VBELV = L_VBELN AND POSNV = S_MC11VA0ITM-POSNR.

...

Former Member
0 Kudos

Hi,

IF ( S_MC11VA0ITM-VBTYP = 'K' OR S_MC11VA0ITM-VBTYP = 'H' ).

CLEAR: DOCCNT, CANCCNT, NOCOUNT.

CLEAR: I_VBFA, L_VBELN.

REFRESH: I_VBFA.

SELECT VBELN POSNN VBTYP_N FROM VBFA INTO TABLE I_VBFA WHERE VBELV = S_MC11VA0ITM-VBELN AND POSNV = S_MC11VA0ITM-POSNR .

LOOP AT I_VBFA.

CASE I_VBFA-VBTYP_N.

WHEN 'O'.

DOCCNT = DOCCNT + 1.

WHEN 'S'.

CANCCNT = CANCCNT + 1.

WHEN OTHERS.

NOCOUNT = NOCOUNT + 1 .

ENDCASE.

ENDLOOP.

IF ( DOCCNT > CANCCNT ) .

S_MC11VA0ITM-ZZCRDBAMT = S_MC11VA0ITM-NETWR.

S_MC11VA0ITM-ZZCRDBQTY = S_MC11VA0ITM-KWMENG.

ENDIF.

ENDIF.

IT WILL PRODUCE CORRECT RESULTS. WHAT EVER THE LOGIC YOU HAVE WRITTEN IS PERFECT. ONLY THING IS YOU NEED TO REFRESH THE INTERNAL TABLE. THERE IS NO NEED OF FIRST SELECT QUERY. WE KNOW IT'S SALES ORDER. WE KNOW SALES ORDER NUMBER IS CORRECT. WHILE EXTRACTING THE DATA IT WON'T GIVE MUCH PERFORMENCE IF YOU USE THIS. YOU WILL GET THE REQUIRED OUTPUT.

ALL THE BEST.

NAGESH.