Tuesday, December 8, 2015

Getting xstring value from Source / URL



Code snippet to get Xstring value from source file either URL or Path File


DATA lr_mime_repository TYPE REF TO if_mr_api.
  
"
  
" Variables
  
DATA lv_img_xstring TYPE xstring.

  
SELECT SINGLE zparam_val1 FROM zett_value
  
INTO gv_img_source
  
WHERE zformtyp 'ED03'
    
AND zparam_id1 'PATH'
    
AND zparam_id2 'NOPHOTO'.


  
TRY.
      
"MIME repository reference
      lr_mime_repository 
cl_mime_repository_api=>get_api( ).

      
"Get file from MIME
      
CALL METHOD lr_mime_repository->get
        
EXPORTING
          i_url             
gv_img_source
          i_check_authority 
' '
        
IMPORTING
          e_content         
lv_img_xstring.

    
CATCH cx_root.
  
ENDTRY.

  
"Return binary representation of file
  gv_image_default 
lv_img_xstring.

Thursday, July 30, 2015

SAPSCRIPT BOX




Simple Box

/: BOX FRAME 10 TW

You can use the POSITION and SIZE commands to set default parameters for a box.

You can write:

/: POSITION XORIGIN '11.21' YORIGIN '5.31' MM 
/: SIZE HEIGHT '2' MM WIDTH '76' MM 
/: BOX FRAME 10 TW INTENSITY 10


This can be useful if you gave several boxes that share the same parameters.

If you want to set the position relatively to the window use POSITION WINDOW
to set the position to the top/left start of the window. Then use POSITION
to set the current position relatively to the start of the Window.

Note that you uses "+" or "-" in the ORIGIN position to the set the position relatively.

/: POSITION WINDOW 
/: POSITION XORIGIN '+5' MM YORIGIN '+10' MM


the position is now 5 MM from the left and 10 MM from the top of the window

Drawing a line. You can draw a line by setting the Height or Widths to 0
and add a frame. E.g. a horizontal line:

/: SIZE HEIGHT '0' MM WIDTH '200' MM

https://pijush.wordpress.com/2007/05/08/to-print-the-total-in-a-sapscript/

Monday, April 27, 2015

ABAP Report - Program Structure or Template




2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
************************************************************************
* Program Name:
* Author:
* Creation Date:
* Description:
* Quality check:
*----------------------------------------------------------------------*
*======================================================================*
* Change History Log
*----------------------------------------------------------------------*
* Date | Change ID | Name | Description | Initials
*----------------------------------------------------------------------*
*
************************************************************************
 
REPORT
 
*-----------------------------------------------------------------------
* TABLE DEFINITIONS
*-----------------------------------------------------------------------
* TABLES: example.
 
*-----------------------------------------------------------------------
* TYPES DEFINITIONS
*-----------------------------------------------------------------------
* TYPES: BEGIN OF texample,
* example TYPE c,
* END OF texample.
 
*-----------------------------------------------------------------------
* TABLE TYPE DEFINITIONS
*-----------------------------------------------------------------------
* TYPES: ttexample TYPE STANDARD TABLE OF texample.
 
*-----------------------------------------------------------------------
* DATA - WORKING FIELDS
*-----------------------------------------------------------------------
* DATA: example TYPE c.
 
*-----------------------------------------------------------------------
* DATA - CONSTANTS
*-----------------------------------------------------------------------
* CONSTANTS:
 
*-----------------------------------------------------------------------
* SELECTION SCREEN
*-----------------------------------------------------------------------
* SELECTION-SCREEN BEGIN OF BLOCK SCR WITH FRAME.
* PARAMETERS: p_example TYPE CHAR255.
* SELECTION-SCREEN END OF BLOCK SCR.
 
************************************************************************
************************** MAIN PROGRAM ********************************
************************************************************************
 
*-----------------------------------------------------------------------
* INITIALIZATION.
*-----------------------------------------------------------------------
 
*-----------------------------------------------------------------------
* AT SELECTION-SCREEN.
*-----------------------------------------------------------------------
 
*-----------------------------------------------------------------------
* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_example.
*-----------------------------------------------------------------------
 
*-----------------------------------------------------------------------
* START-OF-SELECTION.
*-----------------------------------------------------------------------
 
*-----------------------------------------------------------------------
* END-OF-SELECTION.
*-----------------------------------------------------------------------
 
************************************************************************
************************** SUBROUTINES *********************************
************************************************************************

Friday, April 10, 2015

Read Dynamic Table using Fields Symbols


Below is the code snippet.


PARAMETERS p_bukrs TYPE bukrs.

DATA: dref TYPE REF TO data.

AT SELECTION-SCREEN ON p_bukrs.
  FIELD-SYMBOLS:
   TYPE STANDARD TABLE,
   TYPE ANY.

  CREATE DATA dref TYPE STANDARD TABLE OF t001.
  ASSIGN dref->* TO .

  SELECT * FROM t001 INTO TABLE .
  IF sy-subrc = 0.
    SORT  BY ('BUKRS').
    READ TABLE  ASSIGNING 
    WITH KEY ('BUKRS') = p_bukrs.
    IF sy-subrc <> 0.
      MESSAGE 'Invalid Comp. Code' TYPE 'E'.
    ENDIF.
  ENDIF.

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 .

  DATAl_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[]'.
  DATAfield_invfo TYPE char18 VALUE '(SAPLFDCB)INVFO'.
  FIELD-SYMBOLS  TYPE invfo.

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

  ASSIGN (field_invfoTO .
  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 .


  DATAlt_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.