used to History table and fetch some records to getting records in table for this purpose we have to fetch some records
Some time we can check to change in your table for this solution we can fetch some records and value for below solution we can update the records and do operation of the code
TYPES: BEGIN OF ty_cdhdr,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
username TYPE cdusername,
udate TYPE cddatum,
utime TYPE cduzeit,
tcode TYPE cdtcode,
END OF ty_cdhdr.
TYPES: BEGIN OF ty_cdpos,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
tabname TYPE tabname,
tabkey TYPE cdtabkey,
fname TYPE fieldname,
chngind TYPE cdchngind ,
END OF ty_cdpos.
TYPES: BEGIN OF ty_host,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
username TYPE cdusername,
udate TYPE cddatum,
utime TYPE cduzeit,
tcode TYPE cdtcode,
tabname TYPE tabname,
tabkey TYPE cdtabkey,
fname TYPE fieldname,
chngind TYPE cdchngind ,
END OF ty_host.
DATA: gt_cdhdr TYPE STANDARD TABLE OF ty_cdhdr,
gs_cdhdr TYPE ty_cdhdr,
gt_cdpos TYPE STANDARD TABLE OF ty_cdpos,
gs_cdpos TYPE ty_cdpos,
gt_host TYPE STANDARD TABLE OF ty_host,
gs_host TYPE ty_host.
*************************************************** for history table Logic *****************************************************
SELECT objectclas objectid changenr username udate utime tcode
FROM cdhdr
INTO TABLE gt_cdhdr
WHERE objectclas = 'KRED'
AND objectid = wa_final-objectid
AND tcode = 'XK02'
AND udate BETWEEN wa_final-laufd AND sy-datum.
IF sy-subrc EQ 0.
SELECT objectclas objectid changenr tabname tabkey fname chngind
FROM cdpos
INTO TABLE gt_cdpos
FOR ALL ENTRIES IN gt_cdhdr
WHERE objectclas = 'KRED'
AND objectid = gt_cdhdr-objectid
AND changenr = gt_cdhdr-changenr
AND tabname = 'LFBK'
AND fname = 'KEY'.
ENDIF.
SORT gt_cdpos DESCENDING.
READ TABLE gt_cdpos INTO gs_cdpos INDEX 1.
CONDENSE gs_cdpos-tabkey NO-GAPS.
CLEAR: wa_lfbk-bankn,wa_lfbk-bankl.
move gs_cdpos-tabkey+15(11) to wa_lfbk-bankn.
move gs_cdpos-tabkey+26(12) to wa_lfbk-bankl.
TYPES: BEGIN OF ty_cdhdr,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
username TYPE cdusername,
udate TYPE cddatum,
utime TYPE cduzeit,
tcode TYPE cdtcode,
END OF ty_cdhdr.
TYPES: BEGIN OF ty_cdpos,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
tabname TYPE tabname,
tabkey TYPE cdtabkey,
fname TYPE fieldname,
chngind TYPE cdchngind ,
END OF ty_cdpos.
TYPES: BEGIN OF ty_host,
objectclas TYPE cdobjectcl,
objectid TYPE cdobjectv,
changenr TYPE cdchangenr,
username TYPE cdusername,
udate TYPE cddatum,
utime TYPE cduzeit,
tcode TYPE cdtcode,
tabname TYPE tabname,
tabkey TYPE cdtabkey,
fname TYPE fieldname,
chngind TYPE cdchngind ,
END OF ty_host.
DATA: gt_cdhdr TYPE STANDARD TABLE OF ty_cdhdr,
gs_cdhdr TYPE ty_cdhdr,
gt_cdpos TYPE STANDARD TABLE OF ty_cdpos,
gs_cdpos TYPE ty_cdpos,
gt_host TYPE STANDARD TABLE OF ty_host,
gs_host TYPE ty_host.
*************************************************** for history table Logic *****************************************************
SELECT objectclas objectid changenr username udate utime tcode
FROM cdhdr
INTO TABLE gt_cdhdr
WHERE objectclas = 'KRED'
AND objectid = wa_final-objectid
AND tcode = 'XK02'
AND udate BETWEEN wa_final-laufd AND sy-datum.
IF sy-subrc EQ 0.
SELECT objectclas objectid changenr tabname tabkey fname chngind
FROM cdpos
INTO TABLE gt_cdpos
FOR ALL ENTRIES IN gt_cdhdr
WHERE objectclas = 'KRED'
AND objectid = gt_cdhdr-objectid
AND changenr = gt_cdhdr-changenr
AND tabname = 'LFBK'
AND fname = 'KEY'.
ENDIF.
SORT gt_cdpos DESCENDING.
READ TABLE gt_cdpos INTO gs_cdpos INDEX 1.
CONDENSE gs_cdpos-tabkey NO-GAPS.
CLEAR: wa_lfbk-bankn,wa_lfbk-bankl.
move gs_cdpos-tabkey+15(11) to wa_lfbk-bankn.
move gs_cdpos-tabkey+26(12) to wa_lfbk-bankl.
Comments
Post a Comment