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 possible? date to char

Former Member
0 Likes
2,581

I have very limited ABAP experience, and need to convert

a date variable to an 8-character CHAR variable.

Is there a quick easy way to do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,120

hi,

do this way ..


data : v_date like sy-datum,
         v_char(8) type c.


    v_char = v_date.

Regards,

Santosh

11 REPLIES 11
Read only

Former Member
0 Likes
2,121

hi,

do this way ..


data : v_date like sy-datum,
         v_char(8) type c.


    v_char = v_date.

Regards,

Santosh

Read only

Former Member
0 Likes
2,120

DATA: l_date TYPE dats,
          l_date_c(8).

MOVE l_date TO l_date_c.
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,120
data: datum type sy-datum.
data: date(8) type c.

date = datum.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,120

DATA: v_date1 TYPE string.

v_date1 = sy-datum.

WRITE / v_date1.

Regards

Kathirvel

Read only

Former Member
0 Likes
2,120

Thanks for the responses. Let me expand the problem a bit:

1. I am trying to pass a date field into an existing(non-modifiable) function.

2. The function wants the field as something like DDATE in an 8-character

format.

3. When I try the date to C conversion, I still get the same error:

"The function module interface allows you to specify only fields

of a particular type under "DDATE". The field (my_field) has a different

field type.

How do I determine what field type it wants and what field type I am passing?

Read only

0 Likes
2,120

The actual error msg is : "CALL_FUNCTION_CONFLICT_TYPE"

I

Read only

0 Likes
2,119

What is the function name and how is your field declared?

Read only

Former Member
0 Likes
2,119

Hi

Declare your variable as

<b>

DATA: date type datum.</b>

pass your date to this field

date = yourdate.

pass this variable date to the function module#

This is because the Function Module type ddate is of the data element datum.

This should solve your problem<b></b>

Read only

0 Likes
2,119

I tried the datum declaration as follows:

DATA: ddate TYPE datum.

The remote function I am trying to call (a custom function, not SAP standard).

Here is what I am using to call the remote custom function:

call function 'Z_MY_PR_FUNCTION'

exporting

zekko = xekko

zekpo = xekpo

ddate = my_structure-delivery_date

importing

document_no = l_pr

tables

return = return

exceptions

others = 1.

My delivery_date variable(my_structure-delivery_date) is in the form of a date,

my ddate variable is of the type DATUM.

Here is some of the header information from the remote function(which will

eventually create a Purch. Requisition):

FUNCTION Z_MY_REMOTE_PR_FUNCTION.

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(ZEKKO) LIKE EKKO STRUCTURE EKKO

*" REFERENCE(ZEKPO) LIKE EKPO STRUCTURE EKPO

*" REFERENCE(DDATE) TYPE CHAR8

*" EXPORTING

*" REFERENCE(DOCUMENT_NO) LIKE EBAN-BANFN

*" TABLES

*" RETURN STRUCTURE BAPIRET2

In this function, my DDATE variable gets assign to a bapiebanc-deliv_date variable.

Read only

0 Likes
2,119

Hi

Then the issue might be that the bapiebanc-deliv_date does not match the ddate that you have in your custom function module.

why dont you change the custom function module so that ddate is the same data element as bapiebanc-deliv_date.

then this should solve your problem

Read only

Former Member
0 Likes
2,119

Thanks for all the reponses. I still have not resolved the problem.

After trying several of the suggestions here, I still end up with the

same problem. Even though I pass a character field which has been

assigned a date value, it gets passed as a date to the function, so

apparently ABAP does not have an implicit date-to-char conversion.

Here is a part of the output from the dump:

Name of formal parameter.......: "DDATE".

Name of actual paramter "DDATE".

Type of actual parameter "D".

Lenght of actual parameter 8.

Type of formal parameter "C".

Length of formal parameter 8.

Any suggestions? I'll try anything....