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

How to delete wrong values from the table

Former Member
0 Likes
808

Hi,

I have a field of type SY-DATUM and I am loading data from an external system into BW. The field should be of the format YYYYMMDD (Ex: 20051025). But I have some corrupt data where the field is not in the specified format. Sometimes the date is in othe formats, for example 05/02/054, 20/04/04 and some other formats.

Well, When the field is not in the correct format, I would like to set the field to NULL. Any ideas appreciated.

Thanks

GOva

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
740

Sure, you can check the plausibility of the date.

If the data coming in is not of the correct format for SAP, then you set to initial..

Check out this sample program.



report zrich_0001 .


data: p_date type sy-datum value '65/1/2545'.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.


p_Date = sy-datum.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.

Regards,

RIch HEilman

Sure, you can check the plausibility of the date.

If the data coming in is not of the correct format for SAP, then you set to initial..

Check out this sample program.



report zrich_0001 .


data: p_date type sy-datum value '65/1/2545'.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.


p_Date = sy-datum.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.

Regards,

RIch HEilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
741

Sure, you can check the plausibility of the date.

If the data coming in is not of the correct format for SAP, then you set to initial..

Check out this sample program.



report zrich_0001 .


data: p_date type sy-datum value '65/1/2545'.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.


p_Date = sy-datum.


call function 'DATE_CHECK_PLAUSIBILITY'
     exporting
          date                      = p_date
     exceptions
          plausibility_check_failed = 1
          others                    = 2.

if sy-subrc = 1.
  write:/ 'This date is not a real date'.
else.
  write:/ 'Looks ok to me'.
endif.

Regards,

RIch HEilman

Read only

0 Likes
740

Please make sure to mark you post as solved if you question has been answered completely. THanks.

Regards,

RIch Heilman

Read only

0 Likes
740

Rich,

just finished my testing. Works fine. Thanks

Read only

0 Likes
740

Cool, glad to help.

Regard,

Rich Heilman