Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using set in validation rule

Former Member
0 Likes
9,315

Dear Friends,

I am trying to set a validation rule using set.

The requirement is I have a set of Marketing G/L accounts and a set of Cost centres related to Marketing. Now if I post a transaction to any of Marketing G/L account and try to post entry to any cost centre OTHER THAN that in Marketing cost centre set, this validation should stop me. This will help me to prevent entries going to wrong cost centres.

I tried a lot in OB28. I am stuck up at how to put "check" in validation.

Can anybody help?

Thanks and Regards,

Chandrashekhar

10 REPLIES 10
Read only

Former Member
0 Likes
3,788

Create a SET in GS01 T-Code.

Sample Code:

 SELECT SINGLE * FROM setheader WHERE setname = 'ZCASH_EXPOSURE_ACCTS'.
    IF sy-subrc = 0.
      CONCATENATE setheader-setclass
                  setheader-subclass
                  setheader-setname
                  INTO v_setid.

      CALL FUNCTION 'G_SET_TREE_IMPORT'
        EXPORTING
          client     = sy-mandt
          fieldname  = 'HKONT'
          setid      = v_setid
          tabname    = 'BSIS'
        TABLES
          set_values = i_setvalues.

      LOOP AT i_setvalues.
        MOVE 'I'  TO range_hkont-sign.
        MOVE 'BT' TO range_hkont-option.
        MOVE i_setvalues-from TO range_hkont-low.
        MOVE i_setvalues-to   TO range_hkont-high.
        APPEND range_hkont.
      ENDLOOP.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,788

You have to use GGB0 & add the check in the prerequisite.

If you are using the callup point '0002' then you have the fields BSEG-HKONT (G/L account) & BSEG-KOSTL(Cost Center) which you can use in prerequisite.

@Manas: Did you understand the OP's question at all ?

Edited by: Suhas Saha on Apr 16, 2010 3:28 PM

Read only

Former Member
0 Likes
3,788

Hi Suhas,

Thanks for your immediate reply.

Can you please tell me what check should i add in GGB0.

I tried using BSEG-KOSTL IN <set name> but the result is that I am not able to post to ANY cost centre...!!

Please help.

Thanks and Regards,

Chandrashekhar

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,788

if I post a transaction to any of Marketing G/L account and try to post entry to any cost centre OTHER THAN that in Marketing cost centre set, this validation should stop me.

In the prereuisite you should check:

BSEG-HKONT IN ZGL_SET "G/L Account in the GL Set
AND BSEG-KOSTL NOT IN ZCOST_CENTER "Cost Center is outside the Cost Center set

BR,

Suhas

Read only

Former Member
0 Likes
3,788

Hi Suhas,

I tried the same.

The message i am getting is "The formula was composed upto the first syntax error".

Any other way out?

Thanks and Regards,

Chandrashekhar

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,788

Take help of some functional consultant, they should be able to help you. The UI is a bit cranky, but you have to live with it

Suhas

Read only

Former Member
0 Likes
3,788

Hi Suhas,

I am functional consultant.

I tried using a single value of cost centre in "check". It worked fine. But when I try to use a "set" of cost centre it is not working.

Is there any problem with the set itself?

Thanks and Regards,

Chandrashekhar

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,788

>

> I am functional consultant.

Oops sorry, my bad !!!

Does this work fine for the check on the GL a/c set ?

Read only

Former Member
0 Likes
3,788

Hi Suhas,

It's ok.

Is there anything that I have to say "TRUE" or "FLASE" with regard to condition in "check" ?

Let me know.

Thanks and Regards,

Chandrashekhar

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,788

The prerequisite check always checks if the statement is true. If it is false the validation wont trigger.