cancel
Showing results for 
Search instead for 
Did you mean: 

UDF

former_member621323
Participant
0 Kudos

Hi All,

I want to write a UDF. there will be two input. Concat of DATAB and DATBI and 2nd is KSCHL. These 3 fields will be present in segment E1WBB07 of an IDoc.

sample value of DATAB and DATBI = 04112011 and that of KSCHL = VKA0,VKP0,ZTIN etc.

When concatenated value is euqal,VKA0 will be added to resultlist. If not eqaul then take the value present.

Take this case : IDoc -E1WBB01-E1WBB03 which contains below 4 segments of E1WBB07.

E1WBB07-1: KSCHL=VKP0 DATAB=20092011 DATBI=25092011 KWERT=3.50

E1WBB07-2: KSCHL=VKP0 DATAB=26092011 DATBI=30092011 KWERT=3.50

E1WBB07-3: KSCHL=VKA0 DATAB=26092011 DATBI=30092011 KWERT=2.99

E1WBB07-4: KSCHL=VKP0 DATAB=01102011 DATBI=31129999 KWERT=3.50

now concatenated value of 2 and 3 are same,these are duplicate. From this, only VKA0 will be picked. Finaly, KSCHL of 1,3,4 will be added to resultlist. If there is no duplicate value, then all 4 will be added to resultlist.

Can you provide the code for this. I know using sort by key or format by example can remove duplicate values but I dnt want this as its causing problem.

Points will be given for help.

Regards,

Praveen,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Your Udf should have three entries: KSCHL, DATE, KWERT (with option Context) with:

- these three fields of segment E1WBB07 should be in a same context, so to have E1WBB07-1, E1WBB07-2, E1WBB07-3 and E1WBB07-4 should be in same context, and so a same table.

- DATE is concatenation of DATAB and DATBI.

- be sure to have the same numbers of records for each of your three fields: KSCHL, DATE, KWERT. So use a mapWithDefault.

After that, here's a pseudo-code which can help you, this is perhaps not THE solution, but that's will give the way on how to do it: (I let you to translate it in Java...), as I don't want to do Your job, but just to help you


declare two variables: string v_tmp_KWERT, String v_goNextEntry.

For ( all entries of DATE, i+1, i++) {
   if v_goNextEntry = 'X' {     // KWERT has been already added => go directly to next loop entry !
     v_goNextEntry = ''   // clean your flag
   }
   else {
      If Date[i+1] = Date<i> {        // compare current Date and next Date
        if KSCHL<i>='VKAO' {
		  v_tmp_KWERT = KWERT<i>     // use current KWERT
		}
        if KSCHL[i+1]='VKAO' {
          v_tmp_KWERT = KWERT[i+1]    // use next KWERT
          v_goNextEntry = 'X'         // flag to precise we picked-up next loop entry KWERT, so do not pick a second time during the next loop
		}
/*      note: if for a same context, 'VKAO' is neither inside loop <i> nor [i+1], but in [i+2] (for instance), we do nothing in this loop <i>, the good info will be pick-up during the loop [i+1] ;-)
*/
      }
      else {     // curent and next date are diffrent => get current KWERT
         w_tmp_KWERT = KWERT<i>      // use current KWERT
      }

      result<i> = result(i] + w_tmp_KWERT.
   }  // end of v_go_nextentry
}

I hope this help to develop your UdF.

Regards

Mickael

former_member621323
Participant
0 Kudos

Hi Mickael,

Thnx for your reply. But I dnt want to add KWERT as input. as its not required. I only want two input.

Concat of DATAB and DATBI and KSCHL. the output will be KSCHL only based on the criteria I have explaind in my first post.

Regards,

Praveen.

Answers (1)

Answers (1)

former_member621323
Participant
0 Kudos

Hi All,

Any inputs to this please...?

With Regards,

Praveen.