Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

PLEASE CORRECT THE BELOW CODE!

Former Member
0 Kudos

ENTRIES ARE AS FOLLOWS 30 MIN,80 MIN,1.5 H I NEED TO CALCULATE THE TOTAL TIME IN FORMAT H:M.

THIS IS WHT I HAVE DONE IN SAP SCRIPT.

PERFORM Z_PM_COMMON_DURN IN PROGRAM ZPMLINCLUDE

USING &AFVGD-DAUNO& "DURATION

USING &AFVGD-DAUNE& "UNIT. I.E, MINUTES ,HOURS.

CHANGING &CONV_WORK&

ENDPERFORM

[INCLUDE]

FORM Z_PM_COMMON_DURN

TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

DATA : V_DURATION TYPE AFVGD-DAUNO, "DURATION

V_UNIT TYPE AFVGD-DAUNE, "UNIT

V_TIME(8) TYPE C, "TIME

V_TOTAL(8) TYPE C.

READ TABLE IN_TAB INDEX 1.

V_DURATION = IN_TAB-VALUE.

IF V_UNIT = 'MIN'.

V_TIME = V_DURATION / 60.

ELSEIF V_UNIT = 'H'.

V_TIME = V_DURATION.

V_TOTAL = V_TOTAL + V_TIME.

ENDIF.

READ TABLE OUT_TAB INDEX 1.

MOVE V_TOTAL TO OUT_TAB-VALUE.

MODIFY OUT_TAB INDEX 1.

CLEAR OUT_TAB.

ENDFORM.

PLEASE CORRECT THE ABOVE CODE .....AS IAM NOT GETTING THE ANSWER

REGARDS

essamsaud@yahoo.co.in

3 REPLIES 3

dev_parbutteea
Active Contributor
0 Kudos

Hi,

FORM Z_PM_COMMON_DURN

TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

DATA : V_DURATION TYPE AFVGD-DAUNO, "DURATION

V_UNIT TYPE AFVGD-DAUNE, "UNIT

V_TIME(8) TYPE C, "TIME

V_TOTAL(8) TYPE C.

READ TABLE IN_TAB INDEX 1.

V_DURATION = IN_TAB-VALUE.

<b>READ TABLE IN_TAB INDEX 2.

V_UNIT = IN_TAB-VALUE.</b>

IF V_UNIT = 'MIN'.

V_TIME = V_DURATION / 60.

ELSEIF V_UNIT = 'H'.

V_TIME = V_DURATION.

<b>V_TOTAL = V_TOTAL + V_TIME.</b>

<b>??????</b>

<b>V_TOTAL is of type c. what do you want to do?</b>

ENDIF.

READ TABLE OUT_TAB INDEX 1.

MOVE V_TOTAL TO OUT_TAB-VALUE.

MODIFY OUT_TAB INDEX 1.

CLEAR OUT_TAB.

ENDFORM.

varma_narayana
Active Contributor
0 Kudos

Hi Khan..

Check the changes in the code in BOLD:

READ TABLE OUT_TAB INDEX 1.

<b>write V_TOTAL TO OUT_TAB-VALUE left-justified.</b> "instead of MOVE

MODIFY OUT_TAB INDEX 1.

CLEAR OUT_TAB.

here OUTTAB-VALUE is Type C and length 256. so you need to Align the Value to left.

incase of any further issues debug the subroutine.

<b>reward if Helpful</b>

Former Member
0 Kudos

code seems to be fine.

probably check the command line there will be some issues in that.

or please try to debug the script keeping break-point in ur include program also.

u will come to know where the data is missing.

REWARD ME IF U FIND IT HELPFUL.