cancel
Showing results for 
Search instead for 
Did you mean: 

Change of Time Format

former_member214498
Contributor
0 Kudos

hi

I need to change the time format from 17:00 Hrs to 5:00 PM. Right now the form is showing time like 17:00 HRS. it should be 5 PM.

your help will be extremely appreciated.

Regards

Waseem

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

sorry paste didn't work..

try this logic...

If &time+0(2)& GE 13

&time+0(2)& - 12

Endif.

Regards

SAB

former_member214498
Contributor
0 Kudos

You forgot to write the solution in your reply.

former_member214498
Contributor
0 Kudos

Hi

thanx for ur reply. but its not working. The editor shows a message which says '&time+0(' is not a defined command.

Former Member
0 Kudos

Hi Waseem,

then try the code Ferry posted.. in ur print program... if u cant access print program then u need to write a PERFORM routine in script.

/: PERFORM TEST IN PROGRAM Z_PROG

/: USING &TIME&

/: CHANGING &TIME_PM&

/: ENDPERFORM

in ZTEST report program for routine.....

FORM test TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

READ TABLE in_par WITH KEY 'TIME'.

CHECK sy-subrc = 0.

l_time = in_par-value.

CALL FUNCTION 'HRVE_CONVERT_TIME'

EXPORTING

type_time = 'A'

input_time = l_time

INPUT_AM_PM = 'AM'

IMPORTING

OUTPUT_TIME = o_time

OUTPUT_AM_PM = o_stamp

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ TABLE out_par WITH KEY 'TIME_PM'.

CHECK sy-subrc = 0.

out_par-value = o_time.

MODIFY out_par INDEX sy-tabix.

ENDFORM. "TEST

Regards

SAB

former_member214498
Contributor
0 Kudos

Hi Syed

Thanx for such detailed reply. I made an executable program and called that program using perform. However, when I try to activate that program, it prints a message that ITCSY is not a structure.

Please suggest any improvement.

Former Member
0 Kudos

HI Waseem,

there r 2 possiblities as i known for that error message.

1. Program name in PERFORM in script is not matching with Z_PROG name or Routine name TEST is not matching in Z_PROG name.

2. May be u have written the perform in editor mode but not in Command editor mode.

GOTO --> Change Editor

now u can see the left side command /: or /E or * and right side u have to paste the perform statement.

save and activate.

Now in Z_prog

look for the errors .. if it still say same then double clcik on ITCSY, is it exist in ur SAP or not?

Regards

SAB

former_member214498
Contributor
0 Kudos

AOA Syed

Well I have checked that. I had made the changes in Command Mode with

/: in the Tag Column. I have checked the name of program and form and they are correct. Then I checked for the strcture by double clicking on it and it takes me to the Dictionary where it is present.

The called program type is executable. I have changed it to M but still it gives the same error.

Did this code worked for you. or if you have have snippet of code of the ABAP program with routine, please send it to me and I will compare it with my code.

Regards

waseem

Former Member
0 Kudos

AOA Waseem,

i created a new executable program and pasted this code and i activated it without any problem.

I am not sure whats wrong with ur program...

Sapscript:

/: PERFORM TEST IN PROGRAM Z_PROG

/: USING &TIME&

/: CHANGING &TIME_PM&

/: ENDPERFORM

Report: Z_PROG ( Executable)

REPORT Z_PROG.

FORM test TABLES in_par STRUCTURE itcsy

out_par STRUCTURE itcsy.

data: l_time type sy-uzeit,

o_time type sy-uzeit,

o_stamp(2) type c.

READ TABLE in_par WITH KEY 'TIME'.

CHECK sy-subrc = 0.

l_time = in_par-value.

CALL FUNCTION 'HRVE_CONVERT_TIME'

EXPORTING

type_time = 'A'

input_time = l_time

INPUT_AM_PM = 'AM'

IMPORTING

OUTPUT_TIME = o_time

OUTPUT_AM_PM = o_stamp

.

READ TABLE out_par WITH KEY 'TIME_PM'.

CHECK sy-subrc = 0.

out_par-value = o_time.

MODIFY out_par INDEX sy-tabix.

ENDFORM. "TEST

Regards

SAB

former_member214498
Contributor
0 Kudos

AOA Syed

Thanx a lot for your guidance. It worked finally.

Regards

Waseem

Former Member
0 Kudos

AoA Waseem,

if ur problem is solved.. close the thread and reward to all helpful answers..

Regards

SAB

Answers (1)

Answers (1)

ferry_lianto
Active Contributor
0 Kudos

Hi,

Try the FM: HRVE_CONVERT_TIME

TYPE_TIME A

INPUT_TIME 17:00:00

INPUT_AM_PM PM

Export parameters Value

OUTPUT_TIME 05:00:00

OUTPUT_AM_PM PM

Regards,

Ferry Lianto