10-13-2008 4:20 AM
Dear forumers,
What does the sequence of these codes mean? More specifically, what does REFRESH do to lt_tmp_mchb and why is it needed here?
REFRESH lt_tmp_mchb.
lt_tmp_mchb[] = tt_mchb[].
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb COMPARING matnr werks.
Fuller code snippet:-
DATA:
lt_tmp_mchb TYPE STANDARD TABLE OF ty_mchb WITH HEADER LINE,
lt_tmp_msku TYPE STANDARD TABLE OF ty_msku WITH HEADER LINE.
IF r_n_spe = 'X'.
SELECT matnr werks charg vfdat
INTO TABLE tt_mcha
FROM mcha
WHERE werks IN s_werks
AND vfdat BETWEEN sy-datum AND expire_within.
SORT tt_mcha BY matnr werks charg.
IF tt_mcha[] IS NOT INITIAL.
SELECT matnr werks lgort charg clabs
INTO TABLE tt_mchb
FROM mchb
FOR ALL ENTRIES IN tt_mcha
WHERE matnr = tt_mcha-matnr
AND werks = tt_mcha-werks
AND lgort IN s_lgort
AND charg = tt_mcha-charg
AND lvorm <> 'X'.
SORT tt_mchb BY matnr werks lgort charg.
ENDIF.
lt_tmp_mchb[] = tt_mchb[].
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb COMPARING matnr.
IF lt_tmp_mchb[] IS NOT INITIAL.
SELECT matnr bismt mhdrz meins matkl
INTO TABLE ts_mara
FROM mara
FOR ALL ENTRIES IN lt_tmp_mchb
WHERE matnr = lt_tmp_mchb-matnr
AND matkl IN s_matkl.
SELECT matnr maktx
INTO TABLE ts_makt
FROM makt
FOR ALL ENTRIES IN ts_mara
WHERE matnr = ts_mara-matnr
AND spras = sy-langu.
ENDIF.
REFRESH lt_tmp_mchb.
lt_tmp_mchb[] = tt_mchb[].
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb COMPARING matnr werks.
IF lt_tmp_mchb[] IS NOT INITIAL.
SELECT matnr bwkey bwtar lbkum salk3
INTO TABLE tt_mbew
FROM mbew
FOR ALL ENTRIES IN lt_tmp_mchb
WHERE matnr = lt_tmp_mchb-matnr
AND bwkey = lt_tmp_mchb-werks.
SORT tt_mbew BY matnr bwkey bwtar.
ENDIF.
REFRESH lt_tmp_mchb.
lt_tmp_mchb[] = tt_mchb[].
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb
COMPARING matnr werks lgort.
10-13-2008 4:30 AM
Hi...
REFRESH ITAB or CLEAR ITAB[].
Both these statements to clear the contents of internal table body. As we know where CLEAR ITAB clears the contents of its header line.
In your case...
REFRESH lt_tmp_mchb. <----- *lt_tmp_mchb* table body contents are deleted. So now its empty
lt_tmp_mchb[] = tt_mchb[]. <------- *lt_tmp_mchb* filled with the contents of *tt_mchb*. For this both itabs should have same structure
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb COMPARING matnr werks.<------ You are deleting the repeated entries in *lt_tmp_mchb* by comparing with those two fields.
Thanks,
Naveen.I
10-13-2008 4:26 AM
Hi,
Welcome to SDN,
Refresh Statement Refreshes the Internal table data ( content of hte internal Table).
DELETE ADJACENT DUPLICATES deletes the duplicate entries from the internal table on the basis of matnr werks
Thanks,
Chidanand
10-13-2008 4:30 AM
Hi...
REFRESH ITAB or CLEAR ITAB[].
Both these statements to clear the contents of internal table body. As we know where CLEAR ITAB clears the contents of its header line.
In your case...
REFRESH lt_tmp_mchb. <----- *lt_tmp_mchb* table body contents are deleted. So now its empty
lt_tmp_mchb[] = tt_mchb[]. <------- *lt_tmp_mchb* filled with the contents of *tt_mchb*. For this both itabs should have same structure
DELETE ADJACENT DUPLICATES FROM lt_tmp_mchb COMPARING matnr werks.<------ You are deleting the repeated entries in *lt_tmp_mchb* by comparing with those two fields.
Thanks,
Naveen.I
10-13-2008 4:31 AM
REFRESH lt_tmp_mchb.
lt_tmp_mchb[] = tt_mchb[].
Prior to moving the contents of tt_mchb[] to it_tmp_mchp[].Refresh clears the contents of it_tmp_mchp[] if it contains any data such as initial values or temporary data.
10-13-2008 4:46 AM
Hi,
RERFRESH clears the internal table body contents,
In your code
First lt_tmp_mchb is used to fill internal tables ts_mara, ts_makt.
Then the contents of the internal table lt_tmp_mchb is cleared with REFRESH statement.
And then again same internal table is fill with the contents of tt_mchb.
Regards
Bala Krishna
10-13-2008 9:40 AM