Cl Gui Frontend Services

download Cl Gui Frontend Services

of 38

description

Guide On Cl_GUI_FRONTENT_SERVICES

Transcript of Cl Gui Frontend Services

  • 5/22/2018 Cl Gui Frontend Services

    1/38

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 1

    summary :

    This article demonstrate an introduction to Object Orientation

    demonstrate CL_GUI_FRONTEND_SERVICES class. Is class is

    responsible for all services that involve FrontEnd with the system

    operational services that mean resources available in the operating system

    such as : Create , Delete , Copy , Check Existence, or File

    Directories , Collect information of file versions of the programs , access

    information networks like IP , Hostname , OS Version

    Platform ( OS ( WINDOWS , LINUX ) ) , Exult external programs from SAP ,

    such as OS commands . The main methods of this will be presented

    class , showing what each method does and how to use them .

    About the Author :

    Uderson Luis Fermino , graduated in Computer Science from

    Faculty Research and Teaching ISPA , operates in the market within 2 years as

    Java developer in platforms : ( J2SE , J2EE and J2ME ) , with participation

    in large projects involving these technologies . He is a consultant with ABAP

    experiences REPORT, ALV ( GRID , LIST, BLOCK, OO , TREE,

    HIERARQUICK ) , IDOC , ALE , ONLINE , SAPSCRIPT , SmartForm ,

    NETWEAVER ( JCO , BSP , WebDynpro ) .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 2

    What is Object Orientation ?

    Guidelines to object or to be more need -oriented programming

  • 5/22/2018 Cl Gui Frontend Services

    2/38

    object , is a method of problem solving in which the solution of the

    software reflects real-world objects , all software elements are

    based on real world objects .

    A comprehensive introduction to object orientation as a whole would

    far beyond the limits of the introduction to ABAP Objects . this documentation

    introduces a selection of terms that are used universally in orientation

    object and also occurs in ABAP Objects . In subsequent sessions ,

    continues to discuss in more detail how these terms are used in

    ABAP objects

    objects

    An object is the source code section that contains data and provides

    services. The data form the object's attributes . The services are known

    as methods (also known as operations or functions ) . typically ,

    methods operate on private data ( the attributes , or state of the object ) , which is

    only visible to the methods of the object . Soon the attributes of an object does not

    can be modified directly by the user , but only by methods

    the object . This ensures the internal consistency of the object , these data are the

    private type of the object , we can have public attributes , that are changed the

    their states without the use of methods and attributes of the type protected only

    can be changed by the object .

    classes

    The classes are the body of the object . A class is an instance of a

    object that is loaded in memory to make the handling of attributes and

    methods belonging to the object that the class is instantiated

    Object References

  • 5/22/2018 Cl Gui Frontend Services

    3/38

    In a program , you identify objects using references and addresses

    unique object . Reference objects allows accessing the attributes and

    methods of an object .

    In object-oriented programming , objects usually have

    following properties:

    encapsulation

    Objects restrict the visibility of their resources ( attributes and methods )

    to other users . Every object has an interface , which determines how

    other objects can interact with it . The implementation of the object is

    encapsulated , that is , invisible outside of the object itself .

    polymorphism

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 3

    Methods identical ( same name ) behave differently in

    different classes. Oriented object-oriented constructs contains call

    interfaces. They allow to address methods with the same name in

    different objects . Although the form of addressing is always the same;

    implementation of the method is specific for a particular class.

    heritage

    You can use an existing class to derive a new class.

    Derived classes inherit the data and methods of the superclass . However,

    they can replace existing methods is technique is called on

    load method , or re - writing method , and also add new ones. heritage

    can be analogically compared with the Family Heritage .

    Uses of Object Orientation

  • 5/22/2018 Cl Gui Frontend Services

    4/38

    Below are some advantages of object-oriented programming :

    complex software systems become easier to

    understood, since the object-oriented framework provides an

    much closer representation of reality than the other

    programming techniques.

    In a well-developed object-oriented system , it is possible

    implement changes at class level , without having to make changes

    elsewhere in the system. This reduces the total amount of

    maintenance required.

    Through polymorphism and inheritance in object-oriented programming

    allows reuse individual components .

    In an object-oriented system , the amount of work

    maintenance and overhaul involved is reduced , since many problems

    can be detected and corrected at the design stage .

    To achieve these goals requires :

    Programming languages object-oriented

    Techniques for object oriented programming do not necessarily

    depend languages object-oriented programming . on

    However , the efficiency of object-oriented programming depends

    directly how the techniques of object-oriented programming

    are implemented in the system kernel .

    Tools Object Orientation

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 4

    Tools for object-oriented programs allow you to create

  • 5/22/2018 Cl Gui Frontend Services

    5/38

    in object-oriented object-oriented language . they allow

    that model and store objects and relationships between them .

    Object-Oriented Modeling

    The modeling object- oriented software system is the most

    important , more time consuming and more difficult requirement to achieve

    above objectives . Object-oriented design involves more than

    only the object -oriented programming , and provides logical advantages

    which are independent of the actual implementation .

    In ABAP / 4 you can create objects of different ways , will aprenstado two

    ways:

    Statement object reference , plus the CREATE command

    OBJECT

    Using the MODEL Editor .

    Ref: declaring a type specifying that the object will , object is

    declaration is made by TYPE REF TO.

    SYNTAX:

    TYPE REF TO DATA object_name nome_da_classe_de_referencia .

    eg :

    TYPE REF TO DATA OBJSERVICE CL_GUI_FRONTEND_SERVICES .

    Declaration of an object name OBJSERVICE that makes reference to

    CL_GUI_FRONTEND_SERVICES class.

    To create the object , you use the CREATE OBJECT command. However there

    object creation in OO more instance objects to improve the terms ,

    allocation of data memory references that object .

    SYNTAX:

  • 5/22/2018 Cl Gui Frontend Services

    6/38

    CREATE OBJECT nome_do_objeto_referenciado .

    example

    CREATE OBJECT OBJSERVICE

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 5

    When an object is instantiated in ABAP / 4 , you use the command - > known

    indicator attributes or methods .

    Examples . :

    Using GET_TEMP_DIRECTORY method of OBJSERVICE object.

    OBJSERVICE - > GET_TEMP_DIRECTORY ( CHANGING TEMP_DIR = INITIALFOLDER

    EXCEPTIONS CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 3).

    When the method or class attribute is used STATIC ( statico ) , is not

    necessary to use the " CREATE OBJECT " command , because the methods already reside

    memory , which can be used at any time.

    To use a static method or attribute of a class we use the command

    " = > " Some class methods will be presented

    CL_GUI_FRONTEND_SERVICES , all methods presented here are

    static , where we use the command " = > " to call methods or attributes

    this class .

    NOTE: . Implement static methods are when there is an extreme

    necessity because remembering that when the methods or attributes are

    he allocated in static memory , fida during the program , if

    CL_GUI_FRONTEND_SERVICES of the class during the lifetime of the

  • 5/22/2018 Cl Gui Frontend Services

    7/38

    SAPGUI - FRONTEND .

    The second form presented here is instantiating objects with the help of

    MODEL editor .

    1 Declare the object as already explained .

    TYPE REF TO DATA OBJSERVICE CL_GUI_FRONTEND_SERVICES .

    2 In the ABAP Editor ( this item was used version ) , click on " MODEL " .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 6

    2 Select the Template option / to ABAP objects .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 7

    3 Select the " Create Object " option

    INSTANCE = Name of object

    CLASS = Name of the class that the object is reference.

    The code that is generated :

    CREATE OBJECT OBJSERVICE

    * EXCEPTIONS

    * = 1 NOT_SUPPORTED_BY_GUI

    = 2 * CNTL_ERROR

    * Others = 3

    .

    IF SY - SUBRC < > 0 .

    * MESSAGE ID SY - MSGID TYPE SY - MSGTY NUMBER SY - MSGNO

    * WITH SY - MSGV1 MSGV2 SY- SY - SY - MSGV3 MSGV4 .

    ENDIF .

  • 5/22/2018 Cl Gui Frontend Services

    8/38

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 8

    4 Call of the instantiated object method.

    INSTANCE = Name instantiated object

    CLASS / INTERFACE = name of the class or interface that

    Any object reference.

    METHOD = Method name to be called .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 9

    Note: Because this class are static methods as previously

    explained, it is not necessary to perform this step , you need only inform the

    class and method to call , according to the figure :

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 10

    The CL_GUI_FRONTEND_SERVICES class

    The methods to be described below can be used without instantiating

    class, because these methods are of static type where all the data types

    declared as static when the object is declared can be used to

    any time , as they stay in memory waiting to be used .

    Following is the list of methods and their right below the list is described as

    using each method .

    CHECK_HANDLE

    CLASS_CONSTRUCTOR

    CLIPBOARD_EXPORT

    CLIPBOARD_IMPORT

  • 5/22/2018 Cl Gui Frontend Services

    9/38

    DIRECTORY_BROWSE

    DIRECTORY_CREATE

    DIRECTORY_DELETE

    DIRECTORY_EXIST

    DIRECTORY_GET_CURRENT

    DIRECTORY_LIST_FILES

    DIRECTORY_SET_CURRENT

    ENVIRONMENT_GET_VARIABLE

    ENVIRONMENT_SET_VARIABLE

    EXECUTE

    FILE_COPY

    FILE_DELETE

    FILE_EXIST

    FILE_GET_SIZE

    FILE_GET_VERSION

    FILE_OPEN_DIALOG

    FILE_SAVE_DIALOG

    FILE_GET_ATTRIBUTES

    FILE_SET_ATTRIBUTES

    GET_COMPUTER_NAME

    GET_DESKTOP_DIRECTORY

    GET_DRIVE_TYPE

    GET_FREE_SPACE_FOR_DRIVE

    GET_IP_ADDRESS

    GET_PLATFORM

  • 5/22/2018 Cl Gui Frontend Services

    10/38

    GET_SAPGUI_WORKDIR

    GET_SAPGUI_DIRECTORY

    GET_SYSTEM_DIRECTORY

    GET_TEMP_DIRECTORY

    Get_User_Name

    GET_WINDOWS_DIRECTORY

    GUI_DOWNLOAD

    GUI_UPLOAD

    IS_TERMINAL_SERVER

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 11

    REGISTRY_DELETE_KEY

    REGISTRY_DELETE_VALUE

    REGISTRY_GET_VALUE

    REGISTRY_SET_VALUE

    REGISTRY_GET_DWORD_VALUE

    REGISTRY_SET_DWORD_VALUE

    CONSTRUCTOR

    GET_GUI_PROPERTIES

    CHECK_GUI_SUPPORT

    ADD_SUPPORT_BIT

    REMOVE_SUPPORT_BIT

    GET_GUI_VERSION

    GET_UPLOAD_DOWNLOAD_PATH

    FILE_GET_VERSION

  • 5/22/2018 Cl Gui Frontend Services

    11/38

    Method that returns the version of a particular file must pass the

    address and filename , and CHANGING argument a variable of

    type STRING that will contain the value of the version of the specified file.

    VERSION DATE TYPE STRING .

    CLEAR VERSION.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_GET_VERSION

    EXPORTING

    FILENAME = ' C : \ Adobe \ Reader.0 \ Reader \ AdobeUpdateCheck.exe '

    CHANGING

    VERSION = VERSION

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 3

    WRONG_PARAMETER = 4

    OTHERS = 5 .

    WRITE : / VERSION .

    FILENAME = name of the file to be queried

    VERSION = variable of type string that receives the file version

    consulted

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 12

    GET _IP_ADDRESS

    Method to get the ( Internet Protocol ) IP of the machine running the

    FRONTEND , this method returns a STRING in IP format and must be

  • 5/22/2018 Cl Gui Frontend Services

    12/38

    passed a variable of type STRING to the method, which will contain the value of

    Return of the method containing the IP address .

    DATE : IP TYPE STRING .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => GET_IP_ADDRESS

    RECEIVING

    IP_ADDRESS = IP

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 3

    OTHERS = 4 .

    WRITE : / IP .

    IP_ADDRESS = returns a variable of type String containing the IP

    FrontEnd machine that wheel .

    This method brings only the ip of the machine that is running FRONTEND ,

    can happen we need to know the IP of a particular machine

    network , eg the server , as we have the system variable SY - HOST that

    storing in memory the name HOST SAP server , we discovered

    Server IP, for this kind of problem we can use the function

    RFC_HOST_TO_IP , receiving a name of a particular machine in

    network ( HOST ) and returns the same IP . The arguments must be input and

    output must be variables of type C size Maximum 100 characters .

    Using this function we can discover any IP network .

    IP DATA ( 100 ) TYPE C.

    CALL FUNCTION ' RFC_HOST_TO_IP '

  • 5/22/2018 Cl Gui Frontend Services

    13/38

    EXPORTING

    RFCHOST = ' treinamento03 '

    IMPORTING

    RFCIP = IP

    EXCEPTIONS

    HOST_TO_IP_CONVERSION_ERROR = 1

    OTHERS = 2 .

    WRITE : IP .

    RFCHOST = HOSTNAME receives as input the type C 100 .

    RFCIP = Returns the IP on the HOSTNAME , the return is of type C

    100 .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 13

    GET_COMPUTER_NAME

    Method for capturing the name ( HOST ) of the machine, must pass as

    argument to change a variable of type STRING containing the name of

    machine that is running the FRONTEND .

    DATE HOST TYPE STRING .

    CALL METHOD

    CL_GUI_FRONTEND_SERVICES => GET_COMPUTER_NAME

    CHANGING

    COMPUTER_NAME = HOST

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

  • 5/22/2018 Cl Gui Frontend Services

    14/38

    NOT_SUPPORTED_BY_GUI = 3

    Others = 4 .

    WRITE : / HOST .

    COMPUTER_NAME = Returns the HOSTNAME of the machine that is

    FRONTEND running , with a variable of type STRING .

    Identical to GET_IP_ADDRESS method , this method only returns the

    address of the host machine that is running the FRONTEND , if

    necessary to capture the address name ( HOST ) of a machine of this network

    method will not be able to unable this option you can use the function

    RFC_IP_TO_HOST , which takes as its argument an internet address ( IP /

    INTERNET PROTOCOL ) and returns a variable of type C Maximum Size

    100 characters containing the name of the host ( HOST ) on a

    given IP .

    DATE HOST ( 100 ) TYPE C.

    CALL FUNCTION ' RFC_IP_TO_HOST '

    EXPORTING

    RFCIP = '192 .168.0.3 '

    IMPORTING

    RFCHOST = HOST

    EXCEPTIONS

    IP_TO_HOST_CONVERSION_ERROR = 1

    OTHERS = 2 .

    WRITE : HOST .

    RFCIP = Receives a variable of type c 100 , containing IP .

    RFCHOST = Returns a variable of type c 100 , containing the

  • 5/22/2018 Cl Gui Frontend Services

    15/38

    HOSTNAME on the IP input .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 14

    FILE_DELETE

    Method to delete a particular file , you must pass the address

    (path ) and name of the file to be deleted ( deleted / deleted ) , is a

    variable of type I in the argument that RC will return a number informing

    deletion .

    DATE : RC TYPE I.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_DELETE

    EXPORTING

    FILENAME = ' C : \ test.txt '

    CHANGING

    RC = RC

    EXCEPTIONS

    FILE_DELETE_FAILED = 1

    CNTL_ERROR = 2

    ERROR_NO_GUI = 3

    FILE_NOT_FOUND = 4

    ACCESS_DENIED = 5

    UNKNOWN_ERROR = 6

    NOT_SUPPORTED_BY_GUI = 7

    WRONG_PARAMETER = 8

    Others = 9.

    FILENAME = Receives a variable of type string containing the name of

  • 5/22/2018 Cl Gui Frontend Services

    16/38

    file, concatenated path .

    RC = Variable type I , with 1 indicating that when the action of

    method was successful and 0 failure .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 15

    FILE_GET_SIZE

    Method for capturing the size of a particular file , must pass

    address and file name and a variable of type I , which had the

    information on the size of the specified file .

    DATA: I TYPE SIZE .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_GET_SIZE

    EXPORTING

    FILE_NAME = ' C : \ ping.txt '

    IMPORTING

    FILE_SIZE = SIZE

    EXCEPTIONS

    FILE_GET_SIZE_FAILED = 1

    CNTL_ERROR = 2

    ERROR_NO_GUI = 3

    NOT_SUPPORTED_BY_GUI = 4

    Others = 5 .

    WRITE : / SIZE .

    FILENAME = Receives a variable of type string containing the name of

    file, concatenated path .

    FILE_SIZE = Receives a variable of type I to be loaded by

  • 5/22/2018 Cl Gui Frontend Services

    17/38

    method as the size of the specified file .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 16

    FILE_EXIST

    Method to check whether a file exists or not this method

    receives as a parameter an address and name of a particular file , and

    returns a char from 1 containing the 'X' value if there is no case and SPACE

    hesitates file .

    DATE: v_Result (1) TYPE C.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_EXIST

    EXPORTING

    FILE = ' C : \ Audio \ Speclab \ INSTALL.LOG '

    RECEIVING

    RESULT = v_Result

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    WRONG_PARAMETER = 3

    NOT_SUPPORTED_BY_GUI = 4

    Others = 5 .

    WRITE v_Result .

    FILE = Receives a variable of type string containing the name of

    file, concatenated path .

    RESULT = Returns a 1 if exist and 0 if the file does not

    exists, this variable is of type I.

  • 5/22/2018 Cl Gui Frontend Services

    18/38

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 17

    FILE_COPY

    Method is responsible for copying a file from a particular location,

    elsewhere , for example , copy a file in the C : \ temp directory to

    \ temp2 : . directory C This method takes as argument an address

    origin and the name of the file to be copied and a destination address and the name

    the file will be copied to when .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_COPY

    EXPORTING

    SOURCE = ' C : \ Audio \ Speclab \ INSTALL.LOG '

    DESTINATION = ' C : \ INSTALL.LOG '

    OVERWRITE = 'X'

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    WRONG_PARAMETER = 3

    DISK_FULL = 4

    ACCESS_DENIED = 5

    FILE_NOT_FOUND = 6

    DESTINATION_EXISTS = 7

    UNKNOWN_ERROR = 8

    PATH_NOT_FOUND = 9

    DISK_WRITE_PROTECT = 10

    DRIVE_NOT_READY = 11

  • 5/22/2018 Cl Gui Frontend Services

    19/38

    NOT_SUPPORTED_BY_GUI = 12

    Others = 13 .

    SOURCE = Receives the path and file name to be

    copied , must be a variable of type string .

    DESTINATION = Receives the path and name of the file will

    when to be copied to this destination , the file name does not need to be

    even the SOUCE ( ORIGIN ) .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 18

    DIRECTORY_CREATE

    Method , responsible for creating a certain directory in the System

    Operational, this method is independent of the operating system that

    FRONTEND is running, it adjusts to create directory according each

    Operating system ( Remembering that the commands to create directories

    change from OS to OS ) , this method takes as its argument the address

    along the name of the directory to be created and returns an argument of type I

    that returns a number 0 to -1 for creating and creation error .

    eg :

    RC DATA TYPE I.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => DIRECTORY_CREATE

    EXPORTING

    DIRECTORY = ' C : \ test '

    CHANGING

    RC = RC

    EXCEPTIONS

  • 5/22/2018 Cl Gui Frontend Services

    20/38

    DIRECTORY_CREATE_FAILED = 1

    CNTL_ERROR = 2

    ERROR_NO_GUI = 3

    DIRECTORY_ACCESS_DENIED = 4

    DIRECTORY_ALREADY_EXISTS = 5

    PATH_NOT_FOUND = 6

    UNKNOWN_ERROR = 7

    NOT_SUPPORTED_BY_GUI = 8

    WRONG_PARAMETER = 9

    Others = 10 .

    WRITE RC .

    DIRECTORY = Receives the path of the directory to be created ,

    remembering that a directory is a directory only if it is created

    directly in ROOT , for example, ROOT Windows OS is a letter

    Alphabetical , usually " C : " for the first partition of the hard disk and so

    proceeds to other partitions or drives except the drive

    diskette that begins on ROOT " A: " . For SO " LINUX , UNIX ," and another that

    follow the standard UNIX ROOT starts with the letter " / " regardless of

    partition , only switching to the external drives . With this concept these

    in mind when creating a directory that is not on a ROOT more

    but within a directory , this is called a subdirectory. The data type

    entry is a variable of type string

    RC = Returns a variable of type I containing information about the

    creating the directory or subdirectory .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

  • 5/22/2018 Cl Gui Frontend Services

    21/38

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 19

    DIRECTORY_EXIST

    Method responsible for verifying the existence of a given directory

    or subdirectory , getting as argument the address of the directory to be

    searched and returned a variable of type C , size 1 containing the value

    "X " for the existence of the directory and SPACE to nonexistence .

    DATE RESULT TYPE C.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => DIRECTORY_EXIST

    EXPORTING

    DIRECTORY = ' C : \ test '

    RECEIVING

    RESULT = RESULT

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    WRONG_PARAMETER = 3

    NOT_SUPPORTED_BY_GUI = 4

    Others = 5 .

    WRITE RESULT .

    DIRECTORY = Receives the path and name of the directory to be

    checked, being a variable of type string .

    RESULT = Returns a variable of type c 1 containing the

    verification information .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 20

  • 5/22/2018 Cl Gui Frontend Services

    22/38

    DIRECTORY_DELETE

    Responsible for deletion / deletion of a given directory method , this

    method takes as argument an address for a given directory and

    returns a variable of type c of length 1 , containing 'X' for deletion

    performed successfully and as SPACE deletion not performed .

    DATE : RC TYPE C.

    CALL METHOD CL_GUI_FRONTEND_SERVICES => DIRECTORY_DELETE

    EXPORTING

    DIRECTORY = ' C : \ test '

    CHANGING

    RC = RC

    EXCEPTIONS

    DIRECTORY_DELETE_FAILED = 1

    CNTL_ERROR = 2

    ERROR_NO_GUI = 3

    PATH_NOT_FOUND = 4

    DIRECTORY_ACCESS_DENIED = 5

    UNKNOWN_ERROR = 6

    NOT_SUPPORTED_BY_GUI = 7

    WRONG_PARAMETER = 8

    Others = 9.

    WRITE RC .

    DIRECTORY = Receives the path and name of the directory to be

    deleted , with a variable of type string .

    RC = Returns a variable of type I containing information about the

  • 5/22/2018 Cl Gui Frontend Services

    23/38

    deleting the directory or subdirectory .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 21

    Responsible for checking the operating system method that is running

    the FRONTEND , this method returns a variable of type I, containing an

    certain number that SAP has built a table containing

    for this number , where each number is associated with a platform to

    find the number on the platform class

    CL_GUI_FRONTEND_SERVICES , contains attributes of type constants

    (default values ) containing the type of platform , if we want to return the

    d platform name just check what value contained in these constant relative

    the value returned by the method .

    The constants are :

    HKEY_USERS

    PLATFORM_UNKNOWN

    PLATFORM_WINDOWS95

    PLATFORM_WINDOWS98

    PLATFORM_NT351

    PLATFORM_NT40

    PLATFORM_NT50

    PLATFORM_MAC

    PLATFORM_OS2

    PLATFORM_LINUX

    PLATFORM_HPUX

    PLATFORM_TRU64

  • 5/22/2018 Cl Gui Frontend Services

    24/38

    PLATFORM_AIX

    PLATFORM_SOLARIS

    DATE : DECK TYPE I ,

    NOME_PLATF TYPE STRING .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => GET_PLATFORM

    RECEIVING

    PLATFORM PLATFORM =

    EXCEPTIONS

    ERROR_NO_GUI = 1

    CNTL_ERROR = 2

    NOT_SUPPORTED_BY_GUI = 3

    Others = 4 .

    PLATFORM = Returns a variable of type I, containing an amount

    on the OS .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 22

    To check which number on the SAP stores just use any

    type of multiple condition to find what ever that SAP stores

    number on the OS.

    eg :

    CASE PLATFORM .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_WINDOWS95 .

    NOME_PLATF = ' WN32_95 ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_WINDOWS98 .

    NOME_PLATF = ' WN32_98 ' .

  • 5/22/2018 Cl Gui Frontend Services

    25/38

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_NT351 .

    NOME_PLATF = ' WN32 ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_NT40 .

    NOME_PLATF = ' WN32 ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_NT50 .

    NOME_PLATF = ' WN32 ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_MAC .

    NOME_PLATF = 'MC' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_OS2 .

    NOME_PLATF = 'PM' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_LINUX .

    NOME_PLATF = 'MF ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_HPUX .

    NOME_PLATF = 'MF ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_TRU64 .

    NOME_PLATF = 'MF ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_AIX .

    NOME_PLATF = 'MF ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_SOLARIS .

    NOME_PLATF = 'MF ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_MACOSX .

    NOME_PLATF = 'MF ' .

    WHEN 14 . " PLATFORM_WINDOWSXP

    NOME_PLATF = ' WN32 ' .

    WHEN CL_GUI_FRONTEND_SERVICES = > PLATFORM_UNKNOWN .

  • 5/22/2018 Cl Gui Frontend Services

    26/38

    NOME_PLATF = ' ? ' .

    WHEN OTHERS .

    NOME_PLATF = ' ? ' .

    ENDCASE .

    WRITE NOME_PLATF .

    CL_GUI_FRONTEND_SERVICES = > Where XXX = PLATFORM_XXXX and

    equals the numerical value of each constant.

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 23

    Get_User_Name

    Method responsible for returning user logged into the system , receives as

    argument a variable of type STRING .

    DATE NAME TYPE STRING .

    CALL METHOD CL_GUI_FRONTEND_SERVICES = > Get_User_Name

    CHANGING

    USER_NAME = NAME

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 3

    Others = 4 .

    WRITE NAME .

    USER_NAME = Returns a string variable containing the

    name of the user logged into the system .

    Note: The variable sy - uname , stores are same information, and more

  • 5/22/2018 Cl Gui Frontend Services

    27/38

    is quicker to use than the variable method.

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 24

    EXECUTE

    Method , responsible for performing functions express the SAP system , this

    method is somewhat complex and will be described by the parties.

    Examples of some applications that can be run with this method.

    = NOTEPAD.EXE Notepad

    = Cmd.exe Command Prompt

    = WINWORD.EXE Microsoft Word

    CALC.EXE = Calculator

    Firefox.exe = Internet Browser

    CALL METHOD CL_GUI_FRONTEND_SERVICES = > EXECUTE

    EXPORTING

    DOCUMENT = ''

    APPLICATION = ' cmd.exe '

    PARAMETER = ' ping 192.168.0.4 '

    * = DEFAULT_DIRECTORY

    * MAXIMIZED = 'X' " Initializes Maximized

    * Minimized = 'X' " Initializes Minimized

    * SYNCHRONOUS =

    * OPERATION = ' OPEN '

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

  • 5/22/2018 Cl Gui Frontend Services

    28/38

    BAD_PARAMETER = 3

    FILE_NOT_FOUND = 4

    PATH_NOT_FOUND = 5

    FILE_EXTENSION_UNKNOWN = 6

    ERROR_EXECUTE_FAILED = 7

    SYNCHRONOUS_FAILED = 8

    NOT_SUPPORTED_BY_GUI = 9

    OTHERS = 10 .

    When you run a particular application that requires parameters

    input , such as a command prompt , use the parameter

    APPLICANTION passing this parameter to the name of the application to be

    called, and passes the parameter PARAMETER ( s ) parameters

    needed to run the application .

    Note that in the example is called the DOS command prompt , passing the

    ping command, when the prompt application is opened it will run the command

    ping .

    If needed just open the application can use the parameters :

    Or DOCUMENT APPLICATION .

    Example : I opened a WORD document or block of Note .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 25

    To open an address of internete just pass the URL (Uniform Resorce

    Location ) for the parameter DOCUMENT . Exe : . Www.flino.com.br

    FILE_OPEN_DIALOG

    Responsible for file search method , this method only makes

  • 5/22/2018 Cl Gui Frontend Services

    29/38

    Search specified file , to collect a particular file is

    must use GUI_UPLOAD method. The great advantage of using this

    method is that it allows you to select more than one file and make the

    user to specify the correct file path . This method only serves

    to collect the correct path for a given file after the path

    be collected , it is possible to make various operations, for example, delete

    save copy in memory, etc. ....

    DATE : TYPE IT_TAB FileTable ,

    RC TYPE I.

    REFRESH : IT_TAB .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_OPEN_DIALOG

    EXPORTING

    WINDOW_TITLE = 'Select File'

    DEFAULT_EXTENSION = . ' Doc'

    DEFAULT_FILENAME = ' ABAP.doc '

    FILE_FILTER = . ' Doc'

    Multiselection = 'X'

    CHANGING

    FILE_TABLE = IT_TAB

    RC = RC .

    WINDOW_TITLE = Title of Window .

    DEFAULT_EXTENSION = Extension which should start as standard,

    just start by default , can be changed over the.

    DEFAULT_FILENAME = Name of the file to be searched , which will start

    default and can be changed .

  • 5/22/2018 Cl Gui Frontend Services

    30/38

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 26

    FILE_FILTER = Extension to be collected , the

    files , in this case only files with the specified extension , you can

    be collected.

    Multiselection = Allows the selection of multiple files, where

    X is equivalent to the multiple choice, which begins this option with SPACE .

    All types of input data are of type string .

    FILE_TABLE = Returns a structure of type FILE_TABLE ,

    containing the name (s) ( s) ( s ) file ( s ) selected ( s ) .

    example :

    We will create a Selection - Screen , with block and frame that contain a selectoptions ,

    that stores the ( s ) address ( s ) of the file directory ( s ) or ( s ) .

    This select -options , when triggered by the event " AT SELECTIONSCREEN

    ON VALUE -REQUEST FOR " will call the method , and collect

    addresses multiple files .

    SELECTION -SCREEN BEGIN OF BLOCK WITH M FRAME .

    SELECT - OPTIONS FOR SO_FPATH RLGRAP - FILENAME .

    SELECTION -SCREEN END OF BLOCK M.

    AT SELECTION -SCREEN ON VALUE -REQUEST FOR LOW - SO_FPATH .

    REFRESH : IT_TAB .

    CALL METHOD CL_GUI_FRONTEND_SERVICES => FILE_OPEN_DIALOG

    EXPORTING

    WINDOW_TITLE = 'Select File'

    DEFAULT_EXTENSION = . ' Doc'

  • 5/22/2018 Cl Gui Frontend Services

    31/38

    DEFAULT_FILENAME = ' ABAP.doc '

    FILE_FILTER = . ' Doc'

    Multiselection = 'X'

    CHANGING

    FILE_TABLE = IT_TAB

    RC = RC .

    LOOP AT INTO IT_TAB SO_FPATH - LOW .

    SO_FPATH -SIGN = ' I'.

    SO_FPATH -OPTION = ' EQ' .

    APPEND SO_FPATH .

    ENDLOOP .

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 27

    CL_GUI_FRONTEND_SERVICES - UDERSON LUIS FERMINO

    " I can do everything through Him who strengthens me" ( Philippians 4:13) . page 28

    DIRECTORY_BROWSE

    Method responsible for collecting an address of a given directory

    FILE_OPEN_DIALOG equivalent method. With this method may be

    search in graphical mode selection of certain directories . are

    past three parameters to this method are the three parameters that

    passed are of type STRING is the title of one ( WINDOW_TITLE ) the window

  • 5/22/2018 Cl Gui Frontend Services

    32/38

  • 5/22/2018 Cl Gui Frontend Services

    33/38

  • 5/22/2018 Cl Gui Frontend Services

    34/38

  • 5/22/2018 Cl Gui Frontend Services

    35/38

    declares

  • 5/22/2018 Cl Gui Frontend Services

    36/38

  • 5/22/2018 Cl Gui Frontend Services

    37/38

  • 5/22/2018 Cl Gui Frontend Services

    38/38