cancel
Showing results for 
Search instead for 
Did you mean: 

RFC call in a Webdynpro Java help?

former_member185067
Participant
0 Kudos

Hi all,

I need used in my webdynpro Java a FM that I created in R3. Exactly I need load in a combo box  the results of my function module.

I do it this but not works correctly. I think thats my code is not correctly..Anybody can help me?

public void inicializarPrimerAprobadorTarea( )  {
    //@@begin inicializarPrimerAprobadorTarea()
   //Creamos variable para transformar el login en nombre
   String nombre;
   IModifiableSimpleValueSet valueSet = wdContext.nodeCONTAINER().getNodeInfo().getAttribute("AGENT_APPROVAL").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

    // Obtenemos la primera tarea asociada al los aprobadores
    PP4Model2 pp4model2 = new PP4Model2();
    Z_Hsp_Wf_Gbs_Apro_Pva_Input rfcPrimerAprob = new Z_Hsp_Wf_Gbs_Apro_Pva_Input(pp4model2);
  
    //wdContext.nodeZ_Hsp_Wf_Gbs_Apro_Pva_Output().bind(rfcPrimerAprob);
    try {
rfcPrimerAprob.execute();
  wdContext.nodeOutput_1().invalidate();

  if(rfcPrimerAprob.getOutput().getEx_Subrc()!= 0){
   msgmgr.reportException(rfcPrimerAprob.getOutput().getEx_Mensaje());
  }else{ 
   for( int i=0;i<wdContext.nodeLt_Tabla_Pva().size();i++){
    //Transformamos el login en nombre
    nombre = getNombreUsuario(wdContext.nodeLt_Tabla_Pva().getLt_Tabla_PvaElementAt(i).getApprover_Id());
    //Imprimimos mensajes para ver si está correcto.
    msgmgr.reportSuccess(nombre);
    //Metemos el valor en la variable del container.
    valueSet.put(wdContext.nodeLt_Tabla_Pva().getLt_Tabla_PvaElementAt(i).getApprover_Id(),wdContext.nodeLt_Tabla_Pva().getLt_Tabla_PvaElementAt(i).getApprover_Id());  }
  }
 
}catch (Exception e) {
   msgmgr.reportException("Error. "+e.getMessage());          
}
    //@@end
  }

Any body knows the main steps from call correctly to my FM?

Regards,

C. Castillo

Accepted Solutions (0)

Answers (2)

Answers (2)

Sharathmg
Active Contributor
0 Kudos

What is the exact error? Is the data null? Do elaborate on the issue which you are facing currently.

Also, try to invalidate the node before execution ex: wdContext.nodeOutput_1().invalidate(); before the execute method.

Regards,

Sharath

former_member185067
Participant
0 Kudos

Thank you very much, now my method works correctly:

//@@begin inicializarPrimerAprobadorTarea()
   //Variable para transformar el login en nombre
   String nombre;
   IModifiableSimpleValueSet valueSet = wdContext.nodeCONTAINER().getNodeInfo().getAttribute("AGENT_APPROVAL").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

   // Obtenemos la primera tarea asociada al los aprobadores mediante la función de PPA Z_Hsp_Wf_Gbs_Apro_Pva
   PP4Model2 pp4model2 = new PP4Model2();
   Z_Hsp_Wf_Gbs_Apro_Pva_Input rfcPrimerAprob = new Z_Hsp_Wf_Gbs_Apro_Pva_Input(pp4model2);

   try {
    rfcPrimerAprob.execute();
    wdContext.nodeOutput_1().invalidate();

    if(rfcPrimerAprob.getOutput().getEx_Subrc()!= 0){
     msgmgr.reportException(rfcPrimerAprob.getOutput().getEx_Mensaje());
    }else{ 
     if (rfcPrimerAprob.getOutput().getLt_Tabla_Pva().size()== 0){
      msgmgr.reportException("No existen primeros aprobadores responsables para esta tarea, por favor póngase en contacto con el Administrador de la aplicación");
     }else{
      for(int i=0;i<rfcPrimerAprob.getOutput().getLt_Tabla_Pva().size();i++){

       //Transformamos el login en nombre
       nombre = getNombreUsuario(rfcPrimerAprob.getOutput().getLt_Tabla_Pva().get(i).getApprover_Id());
       if(formInfo.getValue().equals("Inicio")|| formInfo.getValue().equals("Modif")){
        if (nombre.equals(rfcPrimerAprob.getOutput().getLt_Tabla_Pva().get(i).getApprover_Id())){
         msgmgr.reportException("El login: "+rfcPrimerAprob.getOutput().getLt_Tabla_Pva().get(i).getApprover_Id()+"es eliminado de los valores del primer aprobador por no existir en SAP Portal");
        }else{
         //Metemos el valor en la variable del container.
         valueSet.put(rfcPrimerAprob.getOutput().getLt_Tabla_Pva().get(i).getApprover_Id(),nombre); 
         }
        }
      }
     }
    }
   }catch (Exception e) {
    msgmgr.reportException("Error. "+e.getMessage());          
   }
    //@@end
  }

If anybody can be improve please let me know,

Regards all,

C. Castillo

Sharathmg
Active Contributor
0 Kudos

Hello Carlos,

Refine the logic. There are too many if loops which may result in unnecessary iterations.

Try to first separate negative cases from positive case and then execute the positive case separately. Just some old plain re-factoring.

Regards,

Sharath

former_member185067
Participant
0 Kudos

Thank you very much Sharath I will try and let you know.

Regards,

Former Member
0 Kudos

Dear Castillo,

Can you please try to initialize the value set like this & check.

IModifiableSimpleValueSet valueSet = wdContext.getNodeInfo().getAttribute("AGENT_APPROVAL").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();


Thanks & Regards,

Patralekha

former_member185067
Participant
0 Kudos

Thank you very much Patralekha I will try and let you know,

Regards,