1 / 18

ABAP/4 PROGRAMMING

ABAP/4 PROGRAMMING. ABAP Language Syntax(1). 講 師:呂 昇 燦 2000 年 9 月 19 日. System Variables. structure ‘SYST’ display all system variables: sy-index sy-datum sy-tabix sy-uname sy-dbcnt sy-subrc sy-langu sy-tcode

sharis
Télécharger la présentation

ABAP/4 PROGRAMMING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ABAP/4 PROGRAMMING ABAP Language Syntax(1) 講 師:呂 昇 燦 2000 年 9 月 19 日

  2. System Variables structure ‘SYST’ display all system variables: sy-index sy-datum sy-tabix sy-uname sy-dbcnt sy-subrc sy-langu sy-tcode sy-ucomm sy-lsind sy-uzeit ……………...

  3. Retrieve data from your table/structure Add data entries into your tables using program. Include fields of the Structure in your program.

  4. Defining Field String A field string is a type of variable, and is the equivalent of a structure in the DDIC. Field string is defined within an ABAP/4 program Like a structure, a field string is a series of fields grouped together.

  5. Two statements are usually used to defined field string: data: begin of fs1, f1[(l)] [type t] [decimals d] [value ‘xxx’], f2[(l)] [type t] [decimals d] [value ‘xxx’], …… [include structure st1.] end of fs1 or data fs2 like fs1.

  6. Two statements are usually used to defined field string: tables fs1. The tables statement does more than just define a field string: defines a field string gives the program access to a database table of the same name. Tables fs1. Select * from fs1 into fs2 where f1 = ‘xxx’.

  7. Defining Types You can define your own data types using the types statement and base them on existing data types. types t1[(1)] [type t] [decimals d]. types t1 like v1. Ex: types dollars(16) type p decimals 2, types c_date like sy-datum.

  8. Structured Types A user-defined type can be based on the definition of a field string. Types: begin of typename, field1(l), field2(l), field3(l), end of typename.

  9. Type Group Type group ztxt Type-pools ztxt. Types ztxt_dollars type p decimals 2. Program 1 Program 2 Type-pools ztxt. Data f1 type ztxt_dollars. Type-pools ztxt. Data f1 type ztxt_dollars.

  10. Assignment Statements clear :set the value of a variable or a field string to zero move :move a value from one field to another,you can use assignment operator “=“ instead move-corresponding :move from one field string to another where the data types and lengths do not match

  11. Performing Calculation compute add or add-corresponding subtract or subtract-corresponding multiply or multiply-corresponding divide or divide-corresponding

  12. Using the compute statement compute v3 = v1 op v2 [op vn ….] v3 is the receiving variable for result v1,v2 and vn are the operands op is a mathematical operators +, -, *, /, **, DIV ,MOD

  13. Using add and add-corresponding add v1 to v2 v2 is variable being added to v1 is the variable added to v2 add-corresponding s1 to s2 s2 is the field string being add to s1 is the field string added to s2 The syntax for the subtract,multiply,and divide is similar

  14. Common Control Statement • Code the common control statements if, case, do, and while. • Control program sequence using exit, continue, and check.

  15. Common Control Statement • if [not] exp [ and [not] exp ] [ or [not] exp ]. • ….. • [elseif exp.]…... • [else.]…... • endif. • case v1. • when v2 [ or vn ….] …. • when v3 [ or vn ….] …. • [ when others.] • endcase.

  16. Common Control Statement • do [ v1 times ] [ varying f1 from s-c1 next s-c2 [varying f2 from s2-c1 next s2-c2 …]] • enddo. • while exp [ vary f1 from s-c1 next s-c2 [ vary f2 from s2-c1 next s2-c2 …] ….. • [ exit. ] …. • endwhile.

  17. Common Control Statement • Exit • [do/while/select/loop] …. • Continue … • [enddo/endwhile/endselect/endloop] • [do/while/select/loop] …. • Check exp … • [enddo/endwhile/endselect/endloop]

  18. Exercise: write a program that product the output

More Related