Application Development and Automation 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: 
Read only

date conversion issue

former_member219850
Participant
0 Likes
2,378

TYPES : BEGIN OF TY_PO_DETAILS,       

EBELN TYPE EBELN,       

AEDAT TYPE SY-DATUM,       

ERNAM TYPE EKKO-ERNAM,       

END OF TY_PO_DETAILS.

DATA:GT_PO_DETAILS TYPE STANDARD TABLE OF TY_PO_DETAILS,

            GW_PO_DETAILS TYPE TY_PO_DETAILS.

SELECT SINGLE EBELN AEDAT ERNAM

     FROM EKKO

     INTO CORRESPONDING FIELDS OF GW_PO_DETAILS

     WHERE EBELN EQ NAST-OBJKY.

     MOVE GW_PO_DETAILS-AEDAT TO GV_DATE.

     CONCATENATE GV_DATE+6(2)'/'GV_DATE+4(2)'/'GV_DATE+0(4) INTO GV_AEDAT.

     GW_PO_DETAILS-AEDAT = GV_AEDAT.

     APPEND GW_PO_DETAILS TO GT_PO_DETAILS.

Hi guruz,,

I need help in this issue.

I wish to append the value of GV_AEDAT in the internal table GT_PO_DETAILS.

but the length of sy-datum is 8 due to which only 11/03/20 content is getting appended in GW_PO_DETAILS-AEDAT .

please suggest what should I do???..

thanx ,

darshan panchal

1 ACCEPTED SOLUTION
Read only

0 Likes
2,159

To format date types you can use WRITE statement like this:

data gv_date type c length 10.

write aedat to gv_date dd/mm/yyyy.

Regards,

Alberto.

17 REPLIES 17
Read only

Former Member
0 Likes
2,159


Hi,

Please declare AEDAT as char10 in TY_PO_DETAILS structure.

Thanks,

Sree

Read only

0 Likes
2,159

hi sreedevi,

I deed the same but it is not working,

error DBIF_RSQL_INVALID_RSQL is coming.

Read only

0 Likes
2,159

The format of AEDAT is YYYYMMDD, you can try this:

SELECT SINGLE EBELN AEDAT ERNAM

     FROM EKKO

     INTO CORRESPONDING FIELDS OF GW_PO_DETAILS

     WHERE EBELN EQ NAST-OBJKY.

     APPEND GW_PO_DETAILS TO GT_PO_DETAILS.


It's a date in input format.


Regards,

Alberto.

Read only

0 Likes
2,159

hie,,

I wish to have gv_date in dd/mm/yyyy format..

Read only

0 Likes
2,160

To format date types you can use WRITE statement like this:

data gv_date type c length 10.

write aedat to gv_date dd/mm/yyyy.

Regards,

Alberto.

Read only

0 Likes
2,159

i want to again append that gv_date dd/mm/yyyy format into AEDAT field of gt_po_details table.

Read only

0 Likes
2,159

You have two options:

1) Give more length to the field of your structure

     TYPES : BEGIN OF TY_PO_DETAILS,      

               EBELN TYPE EBELN,      

               AEDAT TYPE c length 10,      

               ERNAM TYPE EKKO-ERNAM,      

     END OF TY_PO_DETAILS.

2) Use AEDAT and input format YYYYMMDD

Why do you need in output format? It transform in output format from input format (YYYYMMDD->DD/MM/YYYY) automaticly in SAP.

Regards,

Alberto

Read only

0 Likes
2,159

Hi,

I am printing that date in sap script.

Read only

0 Likes
2,159

Use SET DATE MASK in sapscript

Read only

0 Likes
2,159

I gave type of aedat as c length 10, but I encountered error as DBIF_RSQL_INVALID_RSQL..

Read only

0 Likes
2,159

Please tell me the statement of set date mask.

Read only

0 Likes
2,159

yes, because the lengths not are the same. In that case you have to use two structs (one with aedat type sy-datum and the other with aedat type c length 10) and do the conversion after the SELECT.

Read only

0 Likes
2,159

/:   SET DATE MASK 'DD/MM/YYYY' &date&

Read only

0 Likes
2,159

THANKS BRO

Read only

former_member206650
Active Participant
0 Likes
2,159

hi Darshan,

you can also use the AEDAT as type string.above mentioned data types are also apt .

Read only

DominikKraemer
Active Participant
0 Likes
2,159

Well first of all use FM CONVERT_DATE_TO_EXTERNAL instead of your concatenation. This will keep you from problems once users in europe for example are running your program, as they will get the date in the format they are used to.

Then extend your structure with a new field CONV_DATE char type 10 where you will store the converted date. This will be preventing the dump due to type mismatch while selecting.

Reagrds,

Dominik

Read only

Former Member
0 Likes
2,159

Hi,

Add one more field of char length 10 to the line type and use it to store date in the required format.

Fields of type DATS cannot store date with separator characters.

But why do you need to store the date in that format ? If that is for display purpose, you can simply change display mask while displaying instead of storing the date in internal table in the format.

Regards,

Ashish