Skip to Content
0
Feb 06, 2015 at 10:07 AM

Choose From List and Selection Criteria

589 Views

Hi

I want to put a CFL in a form. This CFL will pick up values from OPRJ (SAP B1 Table: Projects , Object Type = 63)

I adapted the code available from the SDK Sample 17.Choose From List

--------

Private Sub AddChooseFromList()

Try

Dim oCFLs As SAPbouiCOM.ChooseFromListCollection

oCFLs = oForm.ChooseFromLists

Dim oCFL As SAPbouiCOM.ChooseFromList

Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams

oCFLCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)

' Adding 2 CFL, one for the button and one for the edit text.

oCFLCreationParams.MultiSelection = False

oCFLCreationParams.ObjectType = "63"

oCFLCreationParams.UniqueID = "CFL1"

oCFL = oCFLs.Add(oCFLCreationParams)

oCFLCreationParams.UniqueID = "CFL2"

oCFL = oCFLs.Add(oCFLCreationParams)

Catch

MsgBox(Err.Description)

End Try

End Sub

-------------

The code works fine, but unfortunately displays ALL records from OPRJ. I want a shorter list to be displayed.

The SQL for this reduced list is as follows:

SELECT DISTINCT T1. PrjCode, T1.PrjName from RDR1 T0

LEFT JOIN OPRJ T1 on T0.Project = T1.PrjCode

WHERE DateDiff(mm,T0.DocDate,GetDate())<9

ORDER BY T1.PrjCode DESC

-------

Can you give me an idea how I can modify my code?

Or should I use a better method?

I also do not wish to use the method given in the sample because it displays the Projects window and allows unauthorized staff to add new projects.

I would be happier if the CFL could be an "ordinary" CFL, i.e a simple listing only.

Thanks

Leon Lai