cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a UDF using IDoc Segment

Former Member
0 Kudos
301

Hello,

(PI Mapping newbie here - please be gentle )

I'm working on mapping an IDoc to a csv flat file.

I need to interrogate certain fields of the source IDoc and return a particular field.

The IDoc in question is based on HRMD_A09 - Segment E1P0041 (Date Specifications).

I want to return the date value from one of the 12 repeating fields (DAT01 - DAT12) - the one I want will be identified by the date type fields DAR01 - DAR12.

I could create a UDF that passes a total of 25 arguments and build a big horrid if - then - else with 12 nested comparisons - I'd like to think there is a better and cleaner solution possible.

If I pass a whole IDoc Segment to a UDF as an argument, how can I parse the value into the individual components?

I'm reading up and trying to understand the "all values of a context"/"all values of a queue" concepts - not sure that the answer is in this direction.

If I were to write this in ABAP it would be easy - I'd be able to pass the segment as a parameter into a form routine so that it is typed according to the segment, and then I'd be able to write up a "do varying" loop structure.

  l_wa_ee_records-corrected_lsl_date        = me->get_date_type( im_p0041     = ls_p0041
                                                                  im_date_type = 'LS' ).



METHOD get_date_type .

   DATA: l_dar      TYPE datar,
         l_dat      TYPE dardt,
         l_date     TYPE d.

   DO 12 TIMES VARYING l_dar FROM im_p0041-dar01
                             NEXT im_p0041-dar02
               VARYING l_dat FROM im_p0041-dat01
                             NEXT im_p0041-dat02.

     IF l_dar IS INITIAL.
       EXIT.
     ELSEIF l_dar = im_date_type.
       l_date = l_dat.
       EXIT.
     ENDIF.

   ENDDO.



Any ideas will be appreciated - thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Nelson

Unfortunately, UDF does not work with whole segments/structures - it requires individual fields of the source structure as input parameters.

Even if it does, unfortunately also, AFAIK there is no equivalent to the HR ABAP style of syntax in Java - there is no DO VARYING equivalent. Java works primarily with single primitive data types or object references.

You might have to built that gigantic 25 input UDF

Rgds

Eng Swee

Former Member
0 Kudos

Thanks for the response, Eng Swee!

engswee
Active Contributor
0 Kudos

You are welcome. If you no longer have any queries on this matter, please do close the thread.

Answers (0)