Monday, February 16, 2015

Activate MIRO Reference Key (Xref3) - Using Substitution and BADI Techniques



A. Below is the step to activate the Reference Key in the  MIRO - Details screen.

1.  Create Implicit Enhancement in program LMR1MF6Q .
2.  Implement below code.
PERFORM modify_fi_subscreen TABLES t_acscr
                                USING  'XREF3'  'ACTIVE'  '1'.

B.1  User exit Activation for Substitution 

1. Execute tcode GCX2 .
2. Change the line with Application Area = GBLS . Change the value Ex. Program to = ZRGGBS000
3. GO to SE38 . Copy the standard program RGGBS000 to ZRGGBS000
4. Create new exit and paste below code.

*---------------------------------------------------------------------*
*       FORM U111                                                                  *
*---------------------------------------------------------------------*
*       Populate XREF3 BSEG-XREF3
*---------------------------------------------------------------------*
FORM u111 USING xref3 TYPE bseg-xref3 .

  DATA: l_v_lifnr  TYPE lifnr.
  CHECK sy-tcode EQ 'MIRO'.

  FIELD-SYMBOLS  TYPE accit_t.
  FIELD-SYMBOLS  TYPE accit.
*  DATA: field_accit TYPE char18 VALUE '(SAPLMRMP)xaccit[]'.
  DATA: field_invfo TYPE char18 VALUE '(SAPLFDCB)INVFO'.
  FIELD-SYMBOLS  TYPE invfo.

*  ASSIGN (field_accit) TO .
*  CHECK sy-subrc EQ 0.

  ASSIGN (field_invfo) TO .
  CHECK BSEG-MWSKZ = '**' OR BSEG-MWSKZ = 'IG' .
*  IF bseg-bschl = '31'. " Posting Key.
    xref3 = -xref3.
*  ENDIF.


ENDFORM.   


B.2 Step to configure Substitution .

1. This substitution is for  FI checking to save xref3 in BSEG table.
2.  Go to tcode GGB1 - Substitution , Choose Finacial Accounting and Line Item.



3, Create new Substitution  and apply below configuration.



4. Create new Step with selection of BSEG-XREF3



5. Maintain the checking condition . Select Prerequisite icon and choose sy-tcode = 'MIRO'.
6. Choose the Substitution  and key in the Exit name. Activate the Substitution 



C. Activate and Configure for Substitution - User Exit

1. Execute OBBH Tcode - To select the and activate the substitution based on company code.
2. Click new entries for each company code.


D. Display Reference Key(XREF3) in MIR4 transaction

1. Implement BADI - BADI_FDCB_SUBBAS04.
2, Make sure activate all the screen, and hide it (as dummy).
3. There is example of implemetation in BADI - BADI_FDCB_SUBBAS01.
4. Put below code at GET_DATA_FROM_SCREEN_OBJECT method.


METHOD if_ex_badi_fdcb_subbas04~get_data_from_screen_object .


  DATA: lt_doc TYPE STANDARD TABLE OF acc_doc,
        l_xref3 TYPE bseg-xref3,
        l_aworg TYPE acchd-aworg.

  FIELD-SYMBOLS:  TYPE acc_doc.

CHECK sy-tcode = 'MIR4'.
MOVE ex_invfo-gjahr TO l_aworg.
CHECK l_aworg IS NOT INITIAL.

*VALUE(I_AWSYS) LIKE  ACCHD-AWSYS DEFAULT SPACE
  CALL FUNCTION 'AC_DOCUMENT_RECORD'
    EXPORTING
      i_awtyp            = 'RMRP'
      i_awref            = ex_invfo-belnr
      i_aworg            = l_aworg
*     I_AWSYS            =
*     I_AWTYP_INCL       = ' '
*     I_AWTYP_EXCL       = ' '
*     I_BUKRS            = ' '
     I_VALUTYP          = '0'
     X_DIALOG           = ' '
   TABLES
     t_documents        = lt_doc
*   EXCEPTIONS
*     NO_REFERENCE       = 1
*     NO_DOCUMENT        = 2
*     OTHERS             = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CHECK lt_doc[] IS NOT INITIAL.
  READ TABLE lt_doc ASSIGNING  WITH KEY awtyp = 'BKPF'.

  CHECK  IS ASSIGNED.
  SELECT SINGLE xref3 INTO l_xref3 FROM bseg
          WHERE bukrs = ex_invfo-bukrs
            AND gjahr = ex_invfo-gjahr
            AND belnr = -docnr
            AND bschl = '31' .


  IF sy-subrc = 0.
    me->if_ex_badi_fdcb_subbas04~invfo-xref3 = l_xref3.
  ENDIF.

* fill export parameters from interface attributes
  ex_invfo  = me->if_ex_badi_fdcb_subbas04~invfo.


ENDMETHOD.





Wednesday, December 24, 2014

Hide Button or Icon in the ABAP Report



Below is the code snippet

Function  :  'RS_SET_SELSCREEN_STATUS' .


FORM remove_dynamic_sel .
  DATA: t_exclude TYPE STANDARD TABLE OF sypfkey.
  APPEND 'DYNS' TO t_exclude.

  "DYNS is the dynamic selection screen function code.

  CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
    EXPORTING
      p_status  = sy-pfkey
    TABLES
      p_exclude = t_exclude.
ENDFORM.  

Sunday, November 30, 2014

Using Field Symbols


Field Symbols

1. Based on normal programming view. Field symbols will act like pointer.

2. Increased program performance.

Basic Used of Field Symbol






Wednesday, October 29, 2014

Dowload SAPScript Layout Code



Sometimes we need to backup or export our SAPScript code, below is the step


1. Run program RSTXSCRP througn SE38

2. Key in the FORM name, and click run button

3. Save the form with .txt extension, save the form in the desktop.

4. Now you have the SAPScript code in the txt mode




Monday, September 29, 2014

Changing Customer Master Data for Payment Term

There are situation that you need to edit the Customer Master Data in SAP.

In this situation, we want to edit the payment term in of the customer under Company Data.

Basically before you are trying to use any BAPI that changing the data, run the BAPI that get the detail from the system. As for this I'm using BAPI_CUSTOMER_GETDETAIL1.


In this BAPI you will need to enter the appropriate data to get the detail of the Customer.

Then you will get the data of that specific customer
Based on the data that you receive follow that and fill up in the BAPI_CUSTOMER_CHANGEFROMDATA1.
IMPORTANT to change the data, you need to fill up in PI_PERSONALDATA field LASTNAME, CITY, COUNTRY, COUNTRYISO, LANGUP, LANGUP_ISO, CURRENCY, CURRENCY_ISO.

And the field that you need to change (in this case we changing Payment Term). Fill up the first PI_OPT_PERSONALDATA. In that table you just need to fill up the field that you want to change (Payment Term) and also table below it PI_OPT_PERSONALDATAX.

Then fill up the SALESORG, DIVISION, DIVISION_CHANNEL and CUSTOMER No.. Then run it.
If the return is 000, then you BAPI is execute with no error and now you can check using tcode XD03.

Have Fun...!! :)



Sunday, September 7, 2014

Checking if Internal table got specific value



Reading/Checking internal table for specific value.

Below is code is best way to check whether the internal table having the value based on the key.


 READ TABLE my_items WITH KEY model = im_item
             TRANSPORTING NO FIELDS.
  l_index = sy-tabix.
  IF sy-subrc NE 0.
    RAISE failure.
  ENDIF


 TRANSPORTING NO FIELDS addition make its optimize way to make the program run faster perhaps.



Wednesday, April 23, 2014

How to Add Customized Filed (KOB1) Actual Cost Line Items SAP Notes 325546



This guide or how to is following SAP Note 325546.



Assumption: 

1. Enhancement on existing SMOD - COOMEP0
2. Using CI_RKPOS
3. Add ZZAUGBL (Clearing Document) customized field.

Steps:

1. Add the customized field in the CI_RKPOS structure.
2. Data Element should follow AUGBL field from BSEG.



3. Enhance the user exit EXIT_SAPLKAEP_001 (ZXKAEPU01)
4. Add line of code to read the data from table to be populated in customized field

IF i_rep_object = 'OR'.
  
SELECT SINGLE  augdt augbl FROM bseg
    
INTO (cs_record-zzaugdt,cs_record-zzaugbl)
    
WHERE bukrs = cs_record-bukrs
          
AND belnr = cs_record-refbn
          
AND gjahr  = cs_record-gjahr.
*        buzei =

  
SELECT SINGLE xblnr FROM bkpf INTO cs_record-zzxblnr
      
WHERE bukrs = cs_record-bukrs AND belnr = cs_record-refbn
      
AND gjahr = cs_record-gjahr.
ENDIF.

5. Open SM34 to edit the view table V_TKALV.

6. Choose "Field Catalog Information"  and in change mode, add New Entries. For this customized field refer below figure.

Field Structure : KAEP_COAC
Field Name: ZZAUGBL
Field Group: 'K' - for customized field



7. Run back the program the customized should appear in the layout selection.