Skip to Content
-2

Converting date field to text field

i have a query where in date field is populated from a table. and if the condition is failed. i.e if there is no entry for the date. it should display as 'N/A'.

how can i achieve this?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jan 11 at 08:10 AM

    you can easily achieve this using new ABAP syntax. Check below sample code.

    SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

    SELECT matnr,
    CASE
    WHEN ersda = @space
    THEN 'N/A'
    WHEN ersda <> @space
    THEN ersda
    END as date
    INTO @data(li_mara)
    UP TO 10 ROWS
    FROM mara.
    ENDSELECT.
    cl_demo_output=>display( li_mara ).

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 11 at 08:15 AM

    use function coalesce you can achive it. take a look at program:

    DEMO_SQL_EXPR_COALESCE

    Add comment
    10|10000 characters needed characters exceeded