ABAP, uai!

2 Posts

To validate the documents posted on the clearing transactions FB05, FB1K or FB1D, use the GGB0 validation rules.

GGB0_A.JPG

Create an 'EXIT' in the ZGGBR000 program and validate POSTAB structure, as follows:

*&---------------------------------------------------------------------*
*&      Form  compe
*&---------------------------------------------------------------------*
*       Validate blocking payment on clearing document
*----------------------------------------------------------------------*

FORM compe USING bool_data TYPE gb002_015
        
CHANGING b_result.

DATA:   
BEGIN OF t_postab OCCURS 20.
INCLUDE STRUCTURE rfops.
DATA:   
END OF t_postab.

FIELD-SYMBOLS: <fs_postab>
TYPE ANY TABLE.

"Search Open Itens in SAP Memory
ASSIGN ('(SAPMF05A)POSTAB[]') TO <fs_postab>.
t_postab[] = <fs_postab>[].

"Validation Message
LOOP AT t_postab WHERE zlspr NE space.
   b_result = b_false.
  
EXIT.
ENDLOOP.

ENDFORM.                   
"compe


Do not forget to activate the rule in OB28.

Best Regards,

 

Rodrigo Abreu Costa

@digoabreu

 

Galo Doido!

To create Settlement Rules via ABAP  use the K_SRULE_SAVE_UTASK function module. View code:

 
     DATA: t_prps      TYPE TABLE OF prps,

           wa_prps     TYPE prps,
           t_cobrb    
TYPE TABLE OF cobrb,
           wa_cobrb   
TYPE cobrb
.
  
    
"Select WBS Elements
    
SELECT *
      
FROM prps
      
INTO TABLE t_prps
      
WHERE psphi EQ im_projectdefinition-pspnr.
  
    
LOOP AT t_prps INTO wa_prps.
  
       wa_cobrb-objnr      = im_projectdefinition-objnr.
      
ADD 1 TO wa_cobrb-lfdnr
.
  

***    USE THE CONVERSION EXITS !!!
      
CALL FUNCTION 'CONVERSION_EXIT_PERBZ_INPUT'
        
EXPORTING
          
input  = 'PER'
        
IMPORTING
          
output = wa_cobrb-perbz.
  
      
CALL FUNCTION 'CONVERSION_EXIT_OBART_INPUT'
        
EXPORTING
          
input     = 'PEP'
        
IMPORTING
          
output    = wa_cobrb-konty
        
EXCEPTIONS
           not_found =
1
          
OTHERS    = 2.
  
      
IF sy-subrc NE 0.
  
       ENDIF.
  
       wa_cobrb-prozs      =
'100.00'.
       wa_cobrb-kokrs      = wa_prps-pkokr.
       wa_cobrb-bukrs      = wa_prps-pbukr.
       wa_cobrb-ps_psp_pnr = wa_prps-pspnr.
       wa_cobrb-rec_objnr1 = wa_prps-objnr.
  
      
APPEND wa_cobrb TO t_cobrb.
  
     ENDLOOP.


     "Create Settlement Rule
    
CALL FUNCTION 'K_SRULE_SAVE_UTASK'
      
TABLES
         t_cobrb_insert    = t_cobrb
      
EXCEPTIONS
         srule_utask_error =
1
        
OTHERS            = 2.
  
    
IF sy-subrc NE 0.
      
"Implement suitable error handling here
     ENDIF.

 

 

This code can be used in Z report program or in BADI PROJECTDEF_UPDATE.


Best Regards,


Rodrigo Abreu Costa

@digoabreu

 

Galo Doido!