Vous êtes sur la page 1sur 13

How To Open SAP Transaction Using ABAP Function : CC_CALL_TRANSACTION_NEW_TASK .

Program Description: We will be creating a start up program that will call this function and open a n ew transaction for VL03N, and it will skip the first screen while supplying the delivery order number and display the delivery order screen. Here s the ABAP sample source code. Z_CALL_NEW_TASK. WRITE:/ WRITE:/ WRITE:/ This is your main Program . You will see a new session program . Opened after this program is active .

DATA : lv_skscr(1) TYPE c VALUE X , lv_vbeln LIKE LIKP-VBELN VALUE 5572000119', l_st_prscr TYPE tpara, l_it_scrprm TYPE TABLE OF tpara. CLEAR l_st_prscr. CLEAR l_it_scrprm[]. l_st_prscr-paramid = VL . l_st_prscr-partext = lv_vbeln. APPEND l_st_prscr TO l_it_scrprm. CALL FUNCTION CC_CALL_TRANSACTION_NEW_TASK STARTING NEW TASK VL03N DESTINATION NONE EXPORTING transaction = VL03N skip_first_screen = X TABLES paramtab = l_it_scrprm EXCEPTIONS communication_failure = 97 system_failure = 98 OTHERS = 99. IF sy-subrc = 0. Success ELSEIF sy-subrc = 97. Communication Failure EXIT. ELSEIF sy-subrc = 98. System Failure EXIT. ELSE. EXIT. ENDIF.

**************************************************

ABAP SYNTAX - Tutorial1 A ADD for single fields Adds two single fields. Syntax ADD <n> TO <m>. The contents of <n> are added to the contents of <m> and the results are stored in <m>. This is equivalent to: <m> = <m> + <n>. ADD for field sequences Adds sequences of fields in storage. Syntax ADD <n1> THEN <n2> UNTIL <nz> GIVING <m>. ADD <n1> THEN <n2> UNTIL <nz> ACCORDING TO <sel> GIVING <m>. ADD <n1> THEN <n2> UNTIL <nz> TO <m>. ADD <n1> FROM <m1> TO <mz> GIVING <m>. If <n1>, <n2>,..., <nz> is a sequence of fields with the same distance to one an other and if they have the same type and length, these fields are added and the result is stored in <m>. Different variants allow you to limit fields to a subse quence, to include <m> in the sum, and to perform the operation on a sequence of fields that directly follow one another. ADD-CORRESPONDING Adds subfields of structures. Syntax ADD-CORRESPONDING <struc1> TO <struc2>. All the subfields of the structures <struc1> and <struc2> having the same name a re added and the results are stored in <struc2>. ALIASES Defines class-specific alias names for an interface component in ABAP objects. Syntax ALIASES <alias> FOR <intf~comp>. <alias> is defined within a class or interface as synonymous with the interface component <intf~comp>. APPEND

Appends a line or multiple lines to the end of an index table. Syntax APPEND <line> LINES OF <jtab> TO <itab> [ASSIGNING <FS> REFERENCE INTO <dref>]. A line <line> or multiple lines of an internal table <jtab> are appended to inde x table <itab>. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the appended line or the relevant data reference is stored in <dref> after t he statement. ASSIGN Assigns a field to a field symbol. Syntax ASSIGN <f> [INCREMENT <n>] TO <FS> [CASTING [TYPE <t> LIKE <f>] [DECIMALS <d>]] [RANGE <r>]. Data object <f> is assigned to field symbol <FS>. <FS> now points to the data ob ject. After the addition INCREMENT <n>, the storage area that is offset <n> time s by a length of <f> starting with <f> is assigned to the field symbol. Pointed brackets are part of the syntax for field symbol names. The CASTING addition per mits you to cast data objects when assigning field symbols. The RANGE addition d efines the storage area in which either offset/length accesses or the INCREMENT addition are allowed. In Unicode programs, standard access is only allowed withi n the field limits of <f>, but this can be extended with RANGE. In non-Unicode p rograms, standard access is possible up to the boundary of the data segment and can be limited with RANGE. Syntax ASSIGN <dref>->* TO <FS> [CASTING ... ]. Dereferencing of the data reference in <dref>. The data object to which the data reference refers is assigned to field symbol <FS>. AT for event blocks Event keywords for defining event blocks for screen events. Syntax AT SELECTION-SCREEN... AT LINE-SELECTION. AT USER-COMMAND. AT PFn. User actions on a selection screen or on a list trigger certain events in the AB AP runtime environment. The event keywords define event blocks that are called w hen events occur. AT for group change

Change of group when processing loops of extracts and internal tables. Syntax AT NEW <f>. AT END OF <f>. AT FIRST. AT LAST. AT <fg>. The statements are used to process group levels within a loop using an extract d ataset or an internal table. They introduce statement blocks that must be closed with ENDAT. The statements between AT and ENDAT are only executed if the corres ponding group change occurred. AUTHORITY-CHECK Checks user authorization. Syntax AUTHORITY-CHECK OBJECT <object> ID <name1> FIELD <f1> ID <name2> FIELD <f2> ... ID <name10> FIELD <f10>. There is a check if the program user has all the authorizations defined in autho rization object <object>. <name1>,..., <name10> are the authorization fields of the authorization object. <f1>,... <f1>, ..., <f10> are data objects of the prog ram. The value of the data objects is checked against the authorization fields. B BACK Relative position of the output in a list. Syntax BACK. Positions the list output either in the first column of the first line following the page header of the current page or in connection with RESERVE in the first column of the first line of a line block. BREAK-POINT Calls the Debugger. Syntax BREAK-POINT. Interrupts execution of the program and goes to debugging mode. Is used as a tes

t help. Normal program processing is interrupted when this statement is reached and the system goes to a debugger. C CALL CUSTOMER-FUNCTION Calls the customer function modules. Syntax CALL CUSTOMER-FUNCTION <func>... Similar to CALL FUNCTION. The function modules must be programmed and activated within the customer's modification concept. CALL FUNCTION Calls the function modules. Syntax CALL FUNCTION <func> [EXPORTING ... [IMPORTING ... [CHANGING ... [TABLES ... [EXCEPTIONS... [DESTINATION <dest>] [IN UPDATE TASK] [STARTING NEW TASK] [IN BACKGOUND TASK]. fi fi fi fi ei = = = = = a a a a r i... i... i... i... i... ] ] ] ] ]

The program calls either a function module in the same R/3 System, or one from a n external system, depending on the variant of the statement you use. You can ca ll update modules when processing transactions. You can also call functions asyn chronously. The other additions are used to specify actual parameters for the pa rameter interface for the function module, <func>, and to handle exceptions. CALL DIALOG Calls a dialog module. Syntax CALL DIALOG <dialog> [AND SKIP FIRST SCREEN] [EXPORTING... fi = a i... ] [IMPORTING... fi = a i... ] [USING itab]. Calls the dialog module <dial>. A dialog module is an ABAP program with a sequen ce of screens. It does not have to be started using a transaction code, or run i n the same SAP LUW, like the calling program. The additions are used to skip the initial screen in the sequence and specify actual parameters for the parameter interface of the dialog module. CALL METHOD Calls a method in ABAP Objects.

Syntax CALL METHOD <meth> [EXPORTING ... <ii> =.<f i>... ] [IMPORTING ... <ei> =.<g i>... ] [CHANGING ... <ci> =.<f i>... ] [RECEIVING r = h ] [EXCEPTIONS... <ei> = r i... ] [PARAMETER-TABLE <ptab>] [EXCEPTION-TABLE <etab>]. [CALL METHOD]<meth>( ... ). Calls a method <meth>. The additions are used to specify actual parameters for t he parameter interface for the function module and to handle exceptions. The las t two additions pass parameters dynamically in a dynamic method call. Alternativ ely, if the method is called statically, the parameters can be specified using p arenthesis notation (as you can when specifying parameters in a CALL METHOD stat ement). You can also use functional methods with this syntax in operand position s. CALL METHOD OF Calls a method in OLE2 Automation. Syntax CALL METHOD OF <obj> <m>. Calls the method, <m>, of the OLE2 Automation Object, <obj>. CALL SCREEN Calls a screen sequence. Syntax CALL SCREEN <scr> [STARTING AT <X1> <Y1>] [ENDING AT <X2> <Y2>]. Calls the sequence of screens that begins with the screen <scr>. All the screens in the screen sequence belong to the current ABAP program. The screen sequence ends when the program reaches the screen numbered 0. The additions let you call a single screen in a new window. CALL SELECTION-SCREEN Calls a selection screen. Syntax CALL SELECTION-SCREEN <scr> [STARTING AT <x1> <y 1>] [ENDING AT <x2> <y 2>]. Calls a selection screen defined in an ABAP program. The selection screen is pro cessed in the program in the AT SELECTION-SCREEN event. The additions let you ca ll a selection screen in a new window. CALL TRANSACTION

Call a transaction. Syntax CALL TRANSACTION <tcod> [AND SKIP FIRST SCREEN] [USING <itab>]. Calls the transaction <tcod> after having received data from the calling program . At the end of the transaction that has been called, the system returns to the statement following the call in the calling report. The additions are used to sk ip the initial screen in the sequence or to pass a batch input table to the tran saction. CASE Conditional branch. Syntax CASE <f>. Opens a CASE control structure that ends with an ENDCASE statement. The CASE con trol structure allows you to control which statement blocks (introduced by WHEN) are processed, based on the contents of a data object. CATCH Catches a class-based exception. CATCH <cx1> ... <cxn> [INTO <ref>]. You can only use this statement in a TRY-ENDTRY block, where you define a handle r for one or more class-based exceptions. You can use INTO to place a reference to the exception object into the reference variable <ref>. CATCH SYSTEM-EXCEPTIONS Catches a catchable runtime error. Syntax CATCH SYSTEM-EXCEPTIONS <except1> = <rc 1>... <except n> = <rc n>. Introduces a CATCH area, which ends with an ENDCATCH statement. If a catchable r untime error <excepti>, occurs between CATCH and ENDCATCH, the current processin g block is interrupted. The system jumps to the appropriate ENDCATCH statement a nd fills SY-SUBRC with <rc i>. CHECK Conditionally leaves a loop or processing block. Syntax CHECK <logexp>. If the logical expression <logexp> is true, the system continues with the next s tatement. If it is false, processing within the loop is interrupted at the curre

nt loop pass, and the next loop pass is performed. Otherwise the system leaves t he current processing block. In conjunction with selection tables, and inside GE T events, you can use an extra variant of the CHECK statement. CLASS Declaration Declares a class in ABAP Objects. Syntax CLASS <class> DEFINITION [PUBLIC] [INHERITING FROM <superclass>] [ABSTRACT] [FINAL] [CREATE PUBLIC PROTECTED PRIVATE] [FRIENDS <cif1> <cif 2> ...] [DEFERRED] [LOAD]. Introduces the declaration part of a class, <class>. The declaration part ends w ith ENDCLASS and contains the declaration of all the components of the class. Th e PUBLIC addition is generated only by the Class Builder. It defines a global cl ass in the Class Library. The INHERITING FROM addition lets you derive the class , <class>, from a superclass, <superclass>. The ABSTRACT addition defines an abs tract class, which cannot be instantiated. The FINAL addition defines a class th at cannot have any subclasses. The CREATE addition specifies who can instantiate the class. FRIENDS allows you to specify other classes or interfaces, <cif> tha t can access the private components of the class and instantiate objects of the class, independently of the CREATE addition. The DEFERRED addition makes the cla ss known to the program before it is declared. The LOAD addition loads a class e xplicitly from the Class Library. CLASS Implementation

Implements a class in ABAP Objects. Syntax CLASS <class> IMPLEMENTATION. Introduces the implementation part of a class, <class>. The implementation part ends with ENDCLASS and contains the implementation of all the components of the class. CLASS-DATA Declares static attributes of a class or interface. Syntax CLASS-DATA <a>... Like DATA. However, the attribute <a> is declared as a static attribute. Static attributes are not instance-specific. Their content is shared by all instances. CLASS-METHODS Declares static methods of a class or interface. Syntax

CLASS-METHODS <meth>... Like METHODS, except that the method <meth> is declared as a static method. A st atic method can access static attributes and can only trigger static events. CLASS-EVENTS Declares static events of a class or interface. Syntax CLASS-EVENTS <evt>... Like EVENTS, except that the event <evt> is declared as a static attribute. Stat ic events are the only type of event that can be triggered in a static method. CLEANUP Tidies up after class-based exceptions. CLEANUP. Can only be used within a TRY-ENDTRY block, where it defines a control block. If a class-based exception is not caught with a CATCH statement, the system execut es the statements between CLEANUP and ENDTRY, before passing the exception along the call hierarchy. CLEAR Sets a variable to its initial value. Syntax CLEAR <f>. The variable <f>, which can have any data type, is set to an initial value appro priate to its type. CLOSE DATASET Closes a file. Syntax CLOSE DATASET <dsn>. Closes a file opened with OPEN DATASET on the application server. CLOSE CURSOR Closes a database cursor. Syntax CLOSE CURSOR <c>. Closes a cursor opened with OPEN CURSOR. COLLECT

Aggregates lines and then adds them to an internal table. Syntax COLLECT <line> INTO <itab> [ASSIGNING <FS> REFERENCE INTO <dref>]. The system checks whether there is already a table entry that matches the key. I f there is no corresponding entry already in the table, the COLLECT statement ha s the same effect as INSERT. If an entry with the same key already exists, the C OLLECT statement does not append a new line, but adds the contents of the numeri c fields in the work area <line> to the contents of the fields in the existing e ntry. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the in serted line or the relevant data reference is stored in <dref> after the stateme nt. COMMIT Closes a SAP LUW. Syntax COMMIT WORK [AND WAIT] Writes all the database changes and releases all the database locks. Triggers up dating. The AND WAIT addition forces the program to wait until the system has fi nished updating the database. Otherwise, updating is asynchronous. COMMUNICATION Enables two programs to communicate with each other. Syntax COMMUNICATION INIT DESTINATION <dest> ID <id> [additions]. COMMUNICATION ALLOCATE ID <id> [additions]. COMMUNICATION ACCEPT ID <id> [additions]. COMMUNICATION SEND ID <id> BUFFER <f> [additions]. COMMUNICATION RECEIVE ID <id> [additions]. COMMUNICATION DEALLOCATE ID <id> [additions]. The statement initializes, creates, and accepts communication between two progra ms; lets these two programs send and receive data; and then closes the connectio n. COMPUTE Performs numeric operations. Syntax COMPUTE <n> = <expression>. The result of the mathematical operation specified in <expression> is assigned t

o the field <n>. The keyword COMPUTE is optional. CONCATENATE Concatenates (chains) several strings to a string. Syntax CONCATENATE <c1>... <cn> INTO <c> [ SEPARATED BY <s> ] [IN BYTE MODE IN CHARACTER MODE]. This statement concatenates the strings <c1> to <cn> and assigns the result to < c>. The addition SEPARATED BY <s> allows you to specify a character field <s> wh ich is placed in its defined length between the individual fields. In Unicode pr ograms, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions. CONDENSE Removes spaces from a string Syntax CONDENSE <c> [NO-GAPS]. This statement removes any leading blanks from the field <c> and replaces other sequences of blanks by exactly one blank. If the addition NO-GAPS is specified, all blanks are removed. CONSTANTS Declares constant data objects. Syntax CONSTANTS <c>... VALUE [<val> IS INITIAL]...

The syntax is similar to DATA, except that the VALUE addition is required, and t hat internal tables and deep structures cannot be declared as constants The star t value specified in the VALUE addition cannot be changed during the execution o f the program. CONTINUE Ends a loop pass. Syntax CONTINUE. Only possible within loops. This statement terminates the current loop pass and starts the next CONTEXTS Declares a context. Syntax CONTEXTS <c>.

Generates an implicit data type CONTEXT_<c>, which you can use to create context instances CONTROLS Defines a control. Syntax CONTROLS <ctrl> TYPE <ctrl_type>. Defines an ABAP runtime object <ctrl>. This displays data in a particular format on a screen, depending on the type <ctrl_type> Currently, <ctrl_type> may be a table control or tabstrip control CONVERT fr Dates Converts a data into an inverted date form. Syntax CONVERT DATE <d1> INTO INVERTED-DATE <d2>. CONVERT INVERTED-DATE <d1> INTO DATE <d2>. If <d1> and <d2> are date fields in the internal form YYYYMMDD, the nines comple ment of <d1> is placed in field <d2> and vice versa. In inverted date format, th e most recent date has the smaller numerical value CONVERT for Timestamps Converts a timestamp into the correct date and time for the current time zone Syntax CONVERT TIME STAMP <tst> TIME ZONE <tz> INTO DATE <d> TIME <t>. CONVERT DATE <d> TIME <t> INTO TIME STAMP <tst> TIME ZONE <tz>. As long as <tst> has type P(8) or P(11) with 7 decimal placed, and <tz> has type C(6), the time stamp <tst> will be converted to the correct date <d> and time < t> for the time zone <tz>. CONVERT for Text Converts a text into a format that can be sorted alphabetically. Syntax CONVERT TEXT <text> INTO SORTABLE CODE <x>. <text> must have type C and <x> must have type X. The string is then converted s o that the relative order of the characters allows them to be sorted alphabetica lly in the current text environment CREATE DATA Creates a dynamic data object.

Syntax CREATE DATA <dref> TYPE <type> LIKE <obj>. CREATE DATA <dref> TYPE LINE OF <itab> LIKE LINE OF <itab>. CREATE DATA <dref> TYPE REF TO DATA <type>. CREATE DATA <dref> TYPE TYPE LIKE <tabkind> OF <linetype> WITH <key>. If <dref> is a data reference variable, a data object of the specified type is c reated. The reference in <dref> points to this object. You can omit the TYPE dec laration in fully-typed reference variables. CREATE OBJECT in ABAP Objects Instantiates an object in ABAP Objects. Syntax CREATE OBJECT <oref> [TYPE <class>] [EXPORTING ... <ii> =.<fi>... ]. <cref> must be a reference variable, defined with reference to a class. CREATE O BJECT then creates an object of that class, to which the reference in <cref> the n points The reference in <dref> points to this object. If <oref> is a typed cla ss reference variable with reference to a subclass of <class>, or if <oref> is a n interface reference variable, whose interface is implemented in the class <cla ss>, you can specify the class of the instantiated object explicitly in a TYPE a ddition, to establish the dynamic type of the reference variables. The EXPORTING addition specifies the non-optional IMPORTING parameters of the instance constr uctor of the class of the instantiated object. CREATE OBJECT in OLE2 Automation Instantiates an external object in OLE2 Automation. Syntax CREATE OBJECT <obj> <class>. If <class> is a class assigned to an automation server, an initial object <obj> of this class is created

Vous aimerez peut-être aussi