cancel
Showing results for 
Search instead for 
Did you mean: 

custom IPC java userexit development for freight condition

Former Member
0 Kudos

Hi Experts,

As per my requirement, I need to write a custom java userexit for freight condition. I have done all the UserExit development environment setup on my local machine ( as per PricingUserExitManualV105 guide). I have got code written in ECC side (ABAP) for custom pricing routine (mentioned below)

CONSTANTS     : lc_s          TYPE rsscr_kind VALUE 'S',

                  lc_eq         TYPE char2      VALUE 'EQ',

                  lc_i          TYPE c          VALUE 'I'.

*--- Local Declaration

  DATA          : lt_tvarvc     TYPE STANDARD TABLE OF tvarvc.

*--- Field symbols

  FIELD-SYMBOLS : <lfs_tvarvc>  TYPE tvarvc,

                  <lfs_auart>   TYPE edm_auart_range.

  SELECT * FROM tvarvc INTO TABLE lt_tvarvc

                       WHERE name = 'ZZSD_ZA00_HDR_MAT'

                       AND   type = lc_s.

*BREAK cbade.

  sy-subrc = 4.

  if komp-kposn ne 0.

    check: komp-prsfd ca 'BX'.

    check: komp-kznep = space.

  endif.

  IF lt_tvarvc[] is NOT INITIAL.

    UNASSIGN <lfs_tvarvc>.

    READ TABLE lt_tvarvc ASSIGNING <lfs_tvarvc> with KEY LOW = KOMP-MATNR.

    IF ( <lfs_tvarvc> is ASSIGNED ) AND ( KOMT1-KSCHL = 'ZA00' ).

    sy-subrc = 4.

    ELSE.

    sy-subrc = 0.

    ENDIF.

  else.

    sy-subrc = 0.

  ENDIF.

I am using RequirementAdapter class for this userexit. Would it be OK as per requirement ?

.

Question 1 ) Do i need to define/declare "constants" and "feild-symbols" in Java userexit, as mention in above ABAP code ?

Question2 ) How to write SELECT statement code in Java UserExit ?

Question 3) What would be equivalent code/logic in Java userexit for READ TABLE statement ?

Please do help me with your suggestions/expertise.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yatendra Pal Singh,

SAP  not recommended to directly  read from tables in pricing user exits though there are ways to do it.

Instead of that you can pass the data from ABAP to IPC using pricing BADI "CRM_COND_COM_BADI".

If you more details or examples you can go to the blog

http://scn.sap.com/community/crm/web-channel/blog/2012/09/26/sap-ipc-development-help

Hope this helps you.

Thanks.

Sarath.

Former Member
0 Kudos

Hi Sarath,

Thanks a lot for helpful answer.

Though I knew SAP doesn't recommend direct access to tables and it's alternate is to use CRM_COND_COM_BADI.

But I am still not clear about my questions mentioned in my post.

How would i define "constants" used in ABAP routine ?

Former Member
0 Kudos

Hi Yatendra Pal Singh,

As the Data will pass from BADI to IPC userexits, then the constants can be maintained in BADI directly or you can pass as attributes to userexits.

Former Member
0 Kudos

Hi Sarath,

Please correct me if i am going wrong.

For constant should it be like :

  ABAP side : lc_s          TYPE rsscr_kind VALUE 'S',

  Java code   : (type) Ic_s = item.getAttributeValue("Z-attr-name");

Is that right ?

And what would be equivalent logic for below definition:

DATA          : lt_tvarvc  TYPE STANDARD TABLE OF tvarvc.

Thanks

Former Member
0 Kudos

Hi Yatendra Pal Singh,

Logic has to be written in the BADI and ask them to send a attribute value based on which you can say  true or false for this requirement.

Hope this helps.

Thanks.

Sarath.

Answers (1)

Answers (1)

daniel_ruiz2
Active Contributor
0 Kudos

Hi Yatendra,

Question 1 ) Do i need to define/declare "constants" and "feild-symbols" in Java userexit, as mention in above ABAP code ?

Java has no such thing as  'field-symbols', thanks God for that, so the answer would be a no. And there is no such thing as 'constants' in Java, thou you can reach the same using a final class with a public static final variable of any given type you want.

Question2 ) How to write SELECT statement code in Java UserExit ?

You simply don't, and if you have such in ECC just raise ' ECC user exit is incorrect and should be fixed '... very very popular topic, pretty sure you will have a hard time to prove, but I'm certain you will prove that ECC userExit code in ABAP is a joke (because that code is a joke and I'm fairly positive it was created by an intern or something..)

Question 3) What would be equivalent code/logic in Java userexit for READ TABLE statement ?

as Sarath mentioned above, as soon you implement the BADI in ABAP code and Map the attributes accordingly, you will end up with no collection or Array inside the userExit itself, as stuff has been calculated before in the BADI and only final values have been passed forward to your custom Java code.

Hope it helps, you should read Sarath hyperlink as he compiled a master piece on IPC extensions.

Cheers,

D.

Former Member
0 Kudos

Hi Sarath & Daniel, Thanks for the reply.

Just getting confused. If all logic has to written in CRM_COND_COM_BADI implementation than what would be the use of all Java API's provided for IPC ? ( this might be silly question to ask )

Can you please help me to understand this with some example(related to my above routine code) ? That would be really helpful.

One for query, what would be the approach if ECC routine contains some table(fields) which doesn't exists in CRM side ?

Thanks again

Former Member
0 Kudos

Hi Yatendra Pal Singh,

IPC will be decide factor whether routine has to execute or not.

BADI will support IPC to decide things by sending attribute values to IPC.

if CRM doesn't contain table that are in ECC, the BADI can query to ECC to get data.

Thanks.

Sarath.

Former Member
0 Kudos

Hi Sarath,

You meant to say all logic should be written in BADI and get stored in some attributes. Using Java Userexit i will get the value of these attributes from BADI and will perform the functionality using those attributes ?

Correct me if i am going wrong .

Thanks