DATA : fr_LIFNR TYPE RANGE OF LIFNR,
frs_LIFNR LIKE LINE OF fr_LIFNR,
fs_Return type BAPIRET2 . "bapiRet2_T.
TYPES: BEGIN OF t_LIFNR,
LIFNR type LIFNR,
end of t_LIFNR.
data : gt_LIFNR TYPE TABLE OF t_LIFNR.
ev_Date = sy-datum.
ev_time = sy-uzeit.
" Prepare input parameter
refresh fr_LIFNR.
if is_vendor-from is INITIAL and is_vendor-to is INITIAL.
" empty to get all
elseif is_vendor-to is INITIAL.
clear frs_LIFNR.
frs_LIFNR-sign = ‘I’.
frs_LIFNR-option = ‘EQ’.
frs_LIFNR-low = is_vendor-from.
append frs_LIFNR to fr_LIFNR.
else.
clear frs_LIFNR.
frs_LIFNR-sign = ‘I’.
frs_LIFNR-option = ‘BT’.
frs_LIFNR-low = is_vendor-from.
frs_LIFNR-high = is_vendor-to.
APPEND frs_LIFNR to fr_LIFNR .
ENDIF.
SELECT LIFNR into TABLE @gt_LIFNR
from LFA1
WHERE LIFNR in @fr_LIFNR
and ERDAT GT @iv_date.
SELECT DISTINCT objectID
from CDHDR
where objectClas = ‘KRED’
and ( uDATE GT @iv_date or ( uDATE EQ @iv_date and uTime GT @iv_time ) )
appending TABLE @gt_LIFNR.
SORT gt_LIFNR by LIFNR.
delete ADJACENT DUPLICATES FROM gt_LIFNR COMPARING LIFNR.
if gt_LIFNR is INITIAL.
clear fs_Return.
fs_Return-type = 'W'.
fs_return-Message = 'No Vendor Found'.
APPEND fs_return to return.
return.
endif.
select
from LFA1 as a left JOIN LFBK as b on a~LIFNR = b~LIFNR
LEFT JOIN ADRC as c on a~ADRNR = c~ADDRNUMBER
fields a~LIFNR as vendor, aname1,aNAME2,a~ORT01 as CITY,a~ADRNR ,aSORTL,aPSTLZ,aTELF1,cname1 as addr1 ,c~name2 as addr2
into CORRESPONDING FIELDS OF table @VENDOR_LIST.
if vendor_list is INITIAL.
clear fs_return.
fs_return-type = ‘W’.
fs_return-message = ‘No Vendor Found’.
APPEND fs_return to return.
return.
else.
clear fs_return.
fs_return-type = ‘s’.
fs_return-message = ‘Success’.
APPEND fs_return to return.
return.
ENDIF.
ENDFUNCTION.