Skip to Content
0

how to seperate dmbtr field into two columns with H and S..

Jul 07, 2017 at 08:01 AM

18

avatar image
Former Member

Hi all,

i tried to seperate DMBTR field into two colums by using single select and read statement.

here is my logic:

types :begin of ty_bsis,

bukrs type bkpf-bukrs,

gsber type bsis-gsber,

hkont type bsis-hkont,

DMBTR TYPE BSIS-DMBTR,

shkzg type bsis-shkzg,

end of ty_bsis.

types: begin of ty_final,

bukrs type BSIS-bukrs,

gsber type BSIS-gsber,

hkont type bsis-hkont,

DMBTR_H TYPE BSIS-DMBTR,

DMBTR_S TYPE BSIS-DMBTR,

end of ty_final.

data: it_bsis type TABLE OF TY_bsis ,

WA_bsis TYPE TY_bsis,

WA_bsis_H TYPE TY_BSIS,

WA_bsis_S TYPE TY_BSIS,

it_FINal type TABLE OF TY_FINal,

WA_FINal TYPE TY_Final,

START-OF-SELECTION.

SELECT

bukrs

GSBER

hkont

dmbtr

shkzg from bsis into CORRESPONDING FIELDS OF TABLE it_bsis UP TO 100 rows where bukrs = p_bukrs and hkont in s_hkont AND GSBER IN s_GSBER AND gsber ne space and BUDAT le P_BUDAT .

LOOP AT IT_bsis INTO WA_bsis.

WA_final-BUKRS = WA_bsis-BUKRS.

WA_final-GSBER = WA_bsis-GSBER.

WA_final-HKONT = WA_bsis-HKONT.

read table it_bsis into wa_bsis_h with key GSBER = WA_bsis-GSBER HKONT = WA_bsis-HKONT shkzg = 'H'.

IF SY-SUBRC = 0.

WA_final-DMBTR_H = WA_bsis_H-DMBTR.

ENDIF.

read table it_bsis into wa_bsis_S with key GSBER = WA_bsis-GSBER HKONT = WA_bsis-HKONT shkzg = 'S'.

IF SY-SUBRC = 0.

WA_final-DMBTR_S = WA_bsis_S-DMBTR

. ENDIF.

APPEND WA_FINAL TO IT_FINAL.

endloop.

this logic is only working for first loop from second loop values not changing . i checked upto 10 records in it_final first loop values are repeating in WA_final-DMBTR_h

and WA_final-DMBTR_S for 10 records . but i have different values in it_bsis.

plz help me.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers