2008 Oct 10 5:20 AM
Hi,
i create a fm for a customerize table updation but the records are not insert in to customerize table
FUNCTION zasia_statustkt.
*"----
""Local interface:
*" EXPORTING
*" REFERENCE(TOTALBREAKFIX) LIKE ZASIA_STATUS-STATUS
*" REFERENCE(TOTALENHANCEMENT) LIKE ZASIA_STATUS-STATUS
*" REFERENCE(TOTALPERFORMANCETUNING) LIKE ZASIA_STATUS-STATUS
*" REFERENCE(TOTALNUMBEROFTICKETS) LIKE ZASIA_STATUS-STATUS
*" TABLES
*" ZAIS STRUCTURE ZTKT_STATUS
*"----
DATA: gt_tab LIKE zasia_status OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF gty_tab1 OCCURS 0,
name TYPE zzname,
issuetype TYPE stceg,
start(4) TYPE p DECIMALS 2,
uat(4) TYPE p DECIMALS 2,
wip(4) TYPE p DECIMALS 2,
gcm(4) TYPE p DECIMALS 2,
apd(4) TYPE p DECIMALS 2,
END OF gty_tab1.
DATA: BEGIN OF gty_tab2 OCCURS 0,
mandt TYPE ztkt_status-mandt,
name TYPE ztkt_status-name,
issuetype TYPE ztkt_status-issuetype,
start TYPE ztkt_status-star,
uat TYPE ztkt_status-uat,
wip TYPE ztkt_status-wip,
gcm TYPE ztkt_status-gcm,
apd TYPE ztkt_status-apd,
END OF gty_tab2.
DATA: lv_name TYPE zzname,
lv_name1 TYPE zzname.
DATA: lv_totbfx(2) TYPE n,
lv_totenh(2) TYPE n,
lv_totpfr(2) TYPE n,
lv_tottkt(2) TYPE n.
DATA tflag(1) VALUE 'X'.
DATA: v_bfx(2) TYPE n,
v_bfx1(2) TYPE n,
v_bfx2(2) TYPE n,
v_bfx3(2) TYPE n,
v_bfx4(2) TYPE n,
v_enh(2) TYPE n,
v_enh1(2) TYPE n,
v_enh2(2) TYPE n,
v_enh3(2) TYPE n,
v_enh4(2) TYPE n,
v_pfr(2) TYPE n,
v_pfr1(2) TYPE n,
v_pfr2(2) TYPE n,
v_pfr3(2) TYPE n,
v_pfr4(2) TYPE n.
SELECT * FROM zasia_status INTO TABLE gt_tab.
SELECT * FROM ztkt_status INTO TABLE zais.
SORT gt_tab BY name issuetype.
LOOP AT gt_tab.
CASE gt_tab-status.
WHEN 'START'.
gty_tab1-name = gt_tab-name.
gty_tab1-issuetype = gt_tab-issuetype.
gty_tab1-start = 1.
COLLECT gty_tab1.
WHEN 'UAT'.
gty_tab1-name = gt_tab-name.
gty_tab1-issuetype = gt_tab-issuetype.
gty_tab1-uat = 1.
COLLECT gty_tab1.
WHEN 'WIP'.
gty_tab1-name = gt_tab-name.
gty_tab1-issuetype = gt_tab-issuetype.
gty_tab1-wip = 1.
COLLECT gty_tab1.
WHEN 'GCM'.
gty_tab1-name = gt_tab-name.
gty_tab1-issuetype = gt_tab-issuetype.
gty_tab1-gcm = 1.
COLLECT gty_tab1.
WHEN 'APD'.
gty_tab1-name = gt_tab-name.
gty_tab1-issuetype = gt_tab-issuetype.
gty_tab1-apd = 1.
COLLECT gty_tab1.
ENDCASE.
CLEAR: gty_tab1.
ENDLOOP.
SORT gty_tab1 BY name issuetype.
LOOP AT gty_tab1.
MOVE: gty_tab1-name TO gty_tab2-name.
MOVE: gty_tab1-issuetype TO gty_tab2-issuetype.
MOVE: gty_tab1-start TO gty_tab2-start.
MOVE: gty_tab1-uat TO gty_tab2-uat.
MOVE: gty_tab1-wip TO gty_tab2-wip.
MOVE: gty_tab1-gcm TO gty_tab2-gcm.
MOVE: gty_tab1-apd TO gty_tab2-apd.
APPEND gty_tab2.
ENDLOOP.
CLEAR: gt_tab, gty_tab1.
REFRESH: gt_tab[], gty_tab1[].
SORT gty_tab2 BY name issuetype.
LOOP AT gty_tab2.
IF gty_tab2-issuetype = 'BREAK-FIX'.
v_bfx = v_bfx + gty_tab2-start.
v_bfx1 = v_bfx1 + gty_tab2-uat.
v_bfx2 = v_bfx2 + gty_tab2-wip.
v_bfx3 = v_bfx3 + gty_tab2-gcm.
v_bfx4 = v_bfx4 + gty_tab2-apd.
ENDIF.
IF gty_tab2-issuetype = 'ENHANCEMENT'.
v_enh = v_enh + gty_tab2-start.
v_enh1 = v_enh1 + gty_tab2-uat.
v_enh2 = v_enh2 + gty_tab2-wip.
v_enh3 = v_enh3 + gty_tab2-gcm.
v_enh4 = v_enh4 + gty_tab2-apd.
ENDIF.
IF gty_tab2-issuetype = 'PERFORMANCE TUNING'.
v_pfr = v_pfr + gty_tab2-start.
v_pfr1 = v_pfr1 + gty_tab2-uat.
v_pfr2 = v_pfr2 + gty_tab2-wip.
v_pfr3 = v_pfr3 + gty_tab2-gcm.
v_pfr4 = v_pfr4 + gty_tab2-apd.
ENDIF.
ENDLOOP.
gty_tab2-name = 'Total'(001).
gty_tab2-issuetype = 'BREAK-FIX'.
gty_tab2-start = v_bfx.
gty_tab2-uat = v_bfx1.
gty_tab2-wip = v_bfx2.
gty_tab2-gcm = v_bfx3.
gty_tab2-apd = v_bfx4.
APPEND gty_tab2.
gty_tab2-name = 'Total'(001).
gty_tab2-issuetype = 'ENHANCEMENT'.
gty_tab2-start = v_enh.
gty_tab2-uat = v_enh1.
gty_tab2-wip = v_enh2.
gty_tab2-gcm = v_enh3.
gty_tab2-apd = v_enh4.
APPEND gty_tab2.
gty_tab2-name = 'Total'(001).
gty_tab2-issuetype = 'PERFORMANCE TUNING' .
gty_tab2-start = v_pfr.
gty_tab2-uat = v_pfr1.
gty_tab2-wip = v_pfr2.
gty_tab2-gcm = v_pfr3.
gty_tab2-apd = v_pfr4.
APPEND gty_tab2.
SORT gty_tab2 BY name issuetype.
LOOP AT gty_tab2.
gty_tab2-mandt = sy-mandt.
lv_name = gty_tab2-name.
IF lv_name = lv_name1.
gty_tab2-name = space.
lv_name1 = lv_name.
ELSE.
lv_name1 = lv_name.
ENDIF.
IF tflag = 'X'.
lv_name1 = lv_name.
tflag = 'Y'.
ENDIF.
MODIFY gty_tab2.
ENDLOOP.
lv_totbfx = v_bfx + v_bfx1 + v_bfx2 + v_bfx3 + v_bfx4.
lv_totenh = v_enh + v_enh1 + v_enh2 + v_enh3 + v_enh4.
lv_totpfr = v_pfr + v_pfr1 + v_pfr2 + v_pfr3 + v_pfr4.
lv_tottkt = lv_totbfx + lv_totenh + lv_totpfr.
totalnumberoftickets = lv_tottkt.
totalbreakfix = lv_totbfx.
totalenhancement = lv_totenh.
totalperformancetuning = lv_totpfr.
DELETE ztkt_status FROM zais.
CLEAR zais. REFRESH zais[].
zais[] = gty_tab2[].
PROBLEM IS IN THIS PORTION I AM NOT DO INSERT DATA IN TO CUSTOMERIZE TABLE OR IN ZTABLE.
LOOP AT zais.
INSERT ztkt_status FROM zais.
ENDLOOP.
CLEAR gty_tab2. REFRESH gty_tab2[].
ENDFUNCTION.
PLZ GIVE ME SOLUTION FOR THIS .
Thanks
jayant.
2008 Oct 10 5:23 AM
Hi,
Are you sure that there is a record to be Inserted........I mean is the control going inside the Loop?
2008 Oct 10 5:23 AM
Hi,
Are you sure that there is a record to be Inserted........I mean is the control going inside the Loop?
2008 Oct 10 5:25 AM
2008 Oct 10 5:34 AM
LOOP AT zais.
INSERT ztkt_status FROM zais.
ENDLOOP.
instead of using the above statement
use the below statements
LOOP AT zais.
ztkt_status-fld1 = zais-fld1.
ztkt_status-fld2 = zais-fld2.
ztkt_status-fld3 = zais-fld3.
ztkt_status-fld4 = zais-fld4.
append ztkt_status.
clear ztkt_status.
ENDLOOP.
Regards
Sreeni
2008 Oct 10 5:38 AM
Hello
Instead
LOOP AT zais.
INSERT ztkt_status FROM zais.
ENDLOOP.
try
INSERT ztkt_status FROM TABLE zais ACCEPTING DUPLICATE KEYS.