Skip to main content

Hello everyone,

 

I'm trying to connect table ekpo and lips in order to get the sum of the field LGMNG for every PO and its corresponding VBELN from VBAP and VBELN from VBFA. The pql code I am using is the following one:

BIND("EKPO", PU_SUM("GSR_VBAP", BIND("GSR_VBFA", "GSR_LIPS"."LGMNG")))

 

This works well when I only have unique VBELN from VBFA for a VBELN from VBAP. My problem is when I have differents VBELN from VBFA for one same VBELN from VBAP, as it sums all te quantities as one, when I want it sepparated.

 

In my OLAP TABLE I only want to show the first VBELN from VBFA, so I use this code: BIND("EKPO",PU_FIRST("GSR_VBAP","GSR_VBFA"."VBELN"))

 

but i get the quantities from LGMNG for all the other VBELN from VBFA which belong to the same VBELN from VBAP.

 

I hope can help here. Many thanks.

 

Hi @arturo.orteg11,

 

If I understand correctly, you want the quantities (LGMNG) from LIPS to be shown only for the first corresponding VBELN from VBFA for each VBELN from VBAP. Please correct me if I am wrong.

 

I think you can need to use PU_SUM with case when here for your use case. Bind is correct I think.

 

Try this PQL.

 

BIND("EKPO",

   PU_SUM("GSR_VBAP",

      CASE

        WHEN PU_FIRST("GSR_VBAP", "GSR_VBFA"."VBELN") = "GSR_VBFA"."VBELN"

        THEN "GSR_LIPS"."LGMNG"

        ELSE 0

      END

   )

)

 

Let me know if this gets your desired result.

 

Kind regards,

Sverre Klein


Reply