‎2007 May 24 6:23 PM
Hi All,
I am getting Dum Error in this code where i put arrow mark.
Kindly please help me.
Its too urgent for me.
FUNCTION Z_CUSTOMER_GET_LIST_1.
*"----
""Local interface:
*" TABLES
*" CUSTOMER STRUCTURE ZCUSTOMER_1
*"----
Tables : KNA1 ,KNB1, ADRC, CAWN.
DATA : begin of itab1 occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
sortl like kna1-sortl,
ktokd like kna1-ktokd,
telf1 like kna1-telf1,
telfx like kna1-telfx,
stras like kna1-stras,
regio like kna1-regio,
ADRNR like kna1-adrnr,
ort01 like kna1-ort01,
land1 like kna1-land1,
pstlz like kna1-pstlz,
loevm like kna1-loevm,
nodel like kna1-nodel,
spras like kna1-spras,
end of itab1.
DATA : begin of itab2 occurs 0,
ADDRNUMBER like adrc-ADDRNUMBER,
transpzone like adrc-transpzone,
str_suppl1 like adrc-str_suppl1,
str_suppl2 like adrc-str_suppl2,
end of itab2.
DATA : begin of itab3 occurs 0,
kunnr like knb1-kunnr,
zterm like knb1-zterm,
end of itab3.
DATA : begin of itab4 occurs 0,
atinn like cawn-atinn,
spars like cawn-spras,
end of itab4.
select kunnr name1 sortl ktokd telf1
telfx stras regio ort01 land1
pstlz loevm nodel adrnr from kna1
into corresponding fields of table itab1 where KTOKD EQ 'Z001'
or KTOKD EQ 'Z002'
or KTOKD EQ 'Z003'
or KTOKD EQ 'Z004'
or KTOKD EQ 'ZSAI' .
sort itab1 by kunnr.
loop at itab1.
if itab1-ktokd = 'Z001'.
itab1-ktokd = 'SP'.
modify itab1.
elseif itab1-ktokd = 'Z002'.
itab1-ktokd = 'SH'.
modify itab1.
elseif itab1-ktokd = 'Z003'.
itab1-ktokd = 'PY'.
modify itab1.
elseif itab1-ktokd = 'Z004'.
itab1-ktokd = 'BP'.
modify itab1.
elseif itab1-ktokd = 'ZSAI'.
itab1-ktokd = 'IC'.
modify itab1.
endif.
endloop.
clear customer.
refresh customer.
*select addrnumber str_suppl1 str_suppl2 transpzone from adrc into table itab2.
*sort itab2 by addrnumber.
select kunnr zterm from knb1 into corresponding fields of table itab3.
*
loop at itab1 where ktokd = 'SP' or ktokd = 'BP'.
*
**read table itab2 with key addrnumber = itab1-adrnr binary search.
**if sy-subrc eq 0.
read table itab3 with key kunnr = itab1-kunnr binary search.
if sy-subrc = 0.
*
move-corresponding itab1 to customer.
**move-corresponding itab2 to customer.
move-corresponding itab3 to customer.
*customer-kunnr = itab1-kunnr.
*customer-name1 = itab1-name1.
*customer-sortl = itab1-sortl.
*customer-ktokd = itab1-ktokd.
*customer-telf1 = itab1-telf1.
*customer-telfx = itab1-telfx.
*customer-stras = itab1-stras.
*customer-regio = itab1-regio.
*customer-ort01 = itab1-ort01.
*customer-pstlz = itab1-pstlz.
*customer-loevm = itab1-loevm.
*customer-nodel = itab1-nodel.
*customer-zterm = itab3-zterm.
*
append customer.
*
endif.
endloop.
loop at itab1 where ktokd = 'SH'.
select addrnumber transpzone str_suppl1 str_suppl2
from adrc into itab2
where addrnumber = itab1-adrnr.
if sy-subrc = 0.
*move-corresponding itab2 to customer.
append itab2.
endif.
endselect.
endloop.
loop at itab1 where ktokd = 'SH'.
read table itab2 with key addrnumber = itab1-adrnr binary search.
if sy-subrc = 0.
customer-str_suppl1 = itab2-str_suppl1.
customer-str_suppl2 = itab2-str_suppl2.
customer-transpzone = itab2-transpzone.
modify customer.
-
>endif.
endloop.
*
ENDFUNCTION.
‎2007 May 24 6:37 PM
You're looping at itab1, but trying to modify customer. You don't have a position in customer, so maybe you want to append customer.
Rob
‎2007 May 24 6:37 PM
You're looping at itab1, but trying to modify customer. You don't have a position in customer, so maybe you want to append customer.
Rob
‎2007 May 24 6:39 PM
Try this.
if sy-subrc = 0.
customer-str_suppl1 = itab2-str_suppl1.
customer-str_suppl2 = itab2-str_suppl2.
customer-transpzone = itab2-transpzone.
<b>append customer</b>.
endif.
endloop.
‎2007 May 24 6:44 PM
Hi Subramanyam,
You have refreshed the Internal table and then u r trying to modify it.
(Just above the endif at which u got an error).
according to me it should be Append customer.
*****Dont forget to give points to useful answers
‎2007 May 24 6:46 PM
Try changing your statements to
loop at itab1 where ktokd = 'SH'.
read table itab2 with key addrnumber = itab1-adrnr binary search.
if sy-subrc = 0.
*customer-str_suppl1 = itab2-str_suppl1.
*customer-str_suppl2 = itab2-str_suppl2.
*customer-transpzone = itab2-transpzone.
MODIFY customer FROM itab2.
ENDIF.
ENDLOOP.
This should work since you are actually using a single record from itab2 (so it's like a work area). Otherwise, read your itab2 record into a workarea and then modify customer from that work area.
- April King
‎2007 May 24 7:04 PM
This is my requirment. I need to fetch data from kna1, knb1, adrc and cawn based on these coditions ( between " " )
R/3 Description Table SAP Field Name Comments
SOLD_ KNA1 KUNNR
LONG NAME KNA1 NAME 1
Customer Name KNA1 SORTL
Partner Type KNA1 KTOKD
"Build logic so that the partner type is not sent to ISP but the code is:
Z001 = SP
Z002 = SH
Z003 = PY
Z004 = BP
ZSAI = IC
Do not interface any partner types but those mentioned here."
Telephone KNA1 TELF1
Fax Number KNA1 TELFX
Street Address KNA1 STRAS
Street 2 ADRC STR_SUPPL1
Street 3 ADRC STR_SUPPL2
City KNA1 REGIO
Region KNA1 ORT01
Country KNA1 LAND1
Postal Code KNA1 PSTLZ
Transportation Zone ADRC TRANSPZONE
"Only available for ship to = Z002 "
Payment Term KNB1 ZTERM
"Only available for Sold to & Bill to "
GroupID CAWN ATINN
"Only for Sold to "
Deletion Flag KNA1 LOEVM
"If there is a value in this field it needs to be passed to the ISP to have the record deleted from CP "
Deletion Flag KNA1 NODEL
"If there is a value in this field it needs to be passed to the ISP to have the record deleted from CP "
PLease help me.