2006 Jun 29 3:09 PM
hello experts,
I am pretty new to ABAP. could someone please help me to sort the following mentioned issue.
I have time char (length 6) which is assigned to a data source. Some of the time data in the fields of a flat file are empty. So the system is not accepting empty fields and moreover the time its brining is in
hh:mm: (6 char) format. The actual format is hh:mm:ss
I guess we have to use concatenation to sort this out. Can someone share the code
I used the following code to eliminate blanks
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
RESULT = TRAN_STRUCTURE-/bic/zooh_time.
endif.
All inputs are much appreciated.
Thanks in advance,
Harish Mulaka
2006 Jun 29 3:12 PM
if you have the time in a sy-uzeit type of field,
you can use the write statement to move it to a 8 character field.
example
data: v_time(8).
write sy-uzeit to v_time.
or
data: v_uzeit type sy-uzeit.
write v_uzeit to v_time.
or
concatenate v_uzeit+0(2) ':'
v_uzeit+2(2) ':'
v_uzeit+4(2)
into v_time.
In you case:
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
concatenate TRAN_STRUCTURE-/bic/zooh_time+0(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+2(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+4(2)
into RESULT.
endif.
Regards,
Ravi
if you have the time in a sy-uzeit type of field,
you can use the write statement to move it to a 8 character field.
example
data: v_time(8).
write sy-uzeit to v_time.
or
data: v_uzeit type sy-uzeit.
write v_uzeit to v_time.
or
concatenate v_uzeit+0(2) ':'
v_uzeit+2(2) ':'
v_uzeit+4(2)
into v_time.
In you case:
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
concatenate TRAN_STRUCTURE-/bic/zooh_time+0(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+2(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+4(2)
into RESULT.
endif.
Regards,
Ravi
2006 Jun 29 3:12 PM
if you have the time in a sy-uzeit type of field,
you can use the write statement to move it to a 8 character field.
example
data: v_time(8).
write sy-uzeit to v_time.
or
data: v_uzeit type sy-uzeit.
write v_uzeit to v_time.
or
concatenate v_uzeit+0(2) ':'
v_uzeit+2(2) ':'
v_uzeit+4(2)
into v_time.
In you case:
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
concatenate TRAN_STRUCTURE-/bic/zooh_time+0(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+2(2) ':'
TRAN_STRUCTURE-/bic/zooh_time+4(2)
into RESULT.
endif.
Regards,
Ravi
2006 Jun 29 3:16 PM
Hi,
first take the data in char of lenght 6.
Data : lv_data type char6,
lv_len type i,
lv_time type t.
lv_data = source_data.
lv_len = strlen(lv_data).
case lv_len
when 0.
*----------Dont do any thing Lv_time ...will have 000000 by default.
when 4.
concatenate lv_data '00' into lv_time.
when 6.
lv_time = lv_data.
when 5.
*--------that is hh:mm
concatenate lv_data+0(2) lv_data+3(2) '00' into lv_time.
endcase.
2006 Jun 29 3:18 PM
You can format the time as SAP needs it(XX:XX:XX) and then covert it to internal format (XXXXXX) Then check it if initial.
report zrich_0002 .
data: in_time(6) type c value '09:29:'.
data: fm_time(8) type c.
data: out_time type sy-uzeit.
concatenate in_time '00' into fm_time.
call function 'CONVERT_TIME_INPUT'
exporting
input = fm_time
* PLAUSIBILITY_CHECK = 'X'
importing
output = out_time
* EXCEPTIONS
* PLAUSIBILITY_CHECK_FAILED = 1
* WRONG_FORMAT_IN_INPUT = 2
* OTHERS = 3
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if out_time is initial.
endif.
Regards,
Rich Heilman
2006 Jun 29 3:36 PM
Hello Ravikanth, Rich and Manoj,
Thank you very much for your swift responces.
Ravikanth,
If I am trying your code its bringing time in this 21::0: format.
Rich,
If I am using your code, The load is success but bringing only 00:00:00 to all fields.
Any other inputs guys
Thanks in advance.
Regards,
Harish
2006 Jun 29 3:38 PM
2006 Jun 29 3:45 PM
Hello Rich,
I am using the following code.
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
data: in_time(6) type c value '09:29:'.
data: fm_time(8) type c.
data: out_time type sy-uzeit.
concatenate in_time '00' into fm_time.
call function 'CONVERT_TIME_INPUT'
exporting
input = fm_time
PLAUSIBILITY_CHECK = 'X'
importing
output = out_time
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
WRONG_FORMAT_IN_INPUT = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if out_time is initial.
Regards,
Harish
2006 Jun 29 3:51 PM
2006 Jun 29 4:08 PM
Hello Rich,
Actually I am using the code with proper fields names. but the load is failing with following error.
Record 1 :Value '21:00: ' of characteristic 0TIME is not a number with 000006 spaces <b></b>
Below is the code which I am using.
data: /bic/zooh_time(6) type c value '09:29:'.
data: fm_time(8) type c.
data: out_time type sy-uzeit.
concatenate /bic/zooh_time '00' into fm_time.
call function 'CONVERT_TIME_INPUT'
exporting
input = fm_time
PLAUSIBILITY_CHECK = 'X'
importing
output = out_time
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
WRONG_FORMAT_IN_INPUT = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if out_time is initial.
endif.
Any other hints please.
Thanks and Regards,
Harish
2006 Jun 29 4:11 PM
2006 Jun 29 4:18 PM
Thank you,
I will try debugging it and will get back to you.
Cheers
Harish
2006 Jun 29 4:51 PM
Hello Ravi,
Thank you very much for your help. I got the it fixed with the help of your code.
Rich, Thank you very much for your valuable time to suggest me.
CODE:
if ( TRAN_STRUCTURE-/bic/zooh_time is initial ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '000000' ) or
( TRAN_STRUCTURE-/bic/zooh_time eq '' ).
clear RESULT.
else.
concatenate TRAN_STRUCTURE-/bic/zooh_time+0(2)
TRAN_STRUCTURE-/bic/zooh_time+2(2)
TRAN_STRUCTURE-/bic/zooh_time+4(2)
into RESULT.
endif.
Points are awareded accordingly.
Thanks and Regards,
Harish Mulaka
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |