Simplify SAP R/3 development with Excel VBA/VB RFC  
Home> UserExit>CYPP0004



User Exit for CYPP Sort, Tab. Plant

The system sorts capacity requirements on the planning tables in capacity leveling according to the fields in the sort-layout key. For every field you can specify an ascending or descending sort sequence. The system executes the sort on the basis of the ASCII character set. In this character set, for example, the number 1 has the value 31, SPACE has the value 20. With an ascending sort the value 20 comes before the value 31, that is SPACE before the number 1.

You can use the user exit CYPP0004 to assign other values to the fields and thus change the sort sequence.

Copy to the enhancement the following import parameters:

  • Value of the field to which you want to assign a value (FIELDNAME)
  • Values of the fields for the current requirements group (CURR_BED_GRU)

These values are copied to the user exit for information purposes and are not necessary for the reassignment of values.


You have three orders with the following priorities:

Order 1: Priority '1'

Order 2: Priority '2'

Order 3: Priority ' '

If in the layout key for the field "Priority" you have specified a sort by increasing priority the system generates the following sequence:

Order 3: Priority ' '

Order 1: Priority '1'

Order 2: Priority '2'

If in the layout key for the field "Priority" you have specified a sort by decreasing priority the system generates the following sequence:

Order 2: Priority '2'

Order 1: Priority '1'

Order 3: Priority ' '

You cannot define other sort sequences in the layout key.

For example, for the following sequence of orders you need the user exit CYPP0004:

Requirement 1: Priority '1'

Requirement 2: Priority '2'

Requirement 3: Priority ' '

To achieve this sort you can use the following source text in the program of the user exit:

statics: low_priok like caufvd-priok value 'Z'.
* caufvd-priok wird durch 'Z' ersetzt.
case fieldname.

assign low_priok to <contents>.
when others.



Note the following points:

  • Do not change the contents of the field itself.

This leads to problems in posting. The system does not recognize whether the change to the object is valid or permitted.

  • The STATIC instruction is necessary. A missing STATIC instruction leads to a program termination.

The STATICS instruction defines variable with local visibility but static validity within a procedure (FORM or FUNCTION).

Local visibility means that static variables (as with normal local variables created with DATA) can only be accessed reading and writing within the defining procedure using its name.

Static validity means that the life of the static variables in contrast to normal local variables is not tied to the activity of the defining parameters but to the run time of the program. Static variables are not placed on the stack every time the defining procedure is called up. Instead they exist independently of being called up; they are in the program and therefore retain they value independently of the defining procedure being called up.

  • EXIT_SAPLCYPP01_004: Sorting: Replace Initial Fields