Quantcast
Channel: SCN : Discussion List - SAP Planning and Consolidation, version for SAP NetWeaver
Viewing all articles
Browse latest Browse all 5414

Variable date format in csv ... Transformation mapping

$
0
0

Hi,

 

I have a Transactional data input file in csv format that contains dates in the format: mm/dd/yyyy, however the months and the days are sometimes only one character in length, so the possible combinations are:

 

mm/dd/yyyy

mm/d/yyyy

m/dd/yyyy

m/d/yyyy

 

From this I need to construct a date in the format yyyy.mm

 

I ended up with an *IF statement that tested for the positions of the "/" in the dates.

 

I started by constructing a "truth table" of the possible values:

 

String         1st "/"   2nd "/"

mm/dd/yyyy     3         6          Test for 2nd

m/d/yyyy       2         4          Test for 2nd

mm/d/yyyy      3         5          Test for 1st

m/dd/yyyy      2         5          Default ...

 

And constructed this:

TIME=*IF( *COL(9,4:4) = *STR(/) Then *COL(9,5:8)  + *STR(.0) + *COL(9,1:1);

          *COL(9,6:6) = *STR(/) Then *COL(9,7:10) + *STR(.)  + *COL(9,1:2);

          *COL(9,2:2) = *STR(/) Then *COL(9,6:9)  + *STR(.0) + *COL(9,1:1);

                                     *COL(9,6:9)  + *STR(.)  + *COL(9,1:2))

 

This works perfectly, but it feels very clumsy & I'm wondering if there is a more elegant way of achieving the same objective?

 

Regards,

Peter


Viewing all articles
Browse latest Browse all 5414

Trending Articles