1 / 66

ABAP Chapter 4

ABAP Chapter 4. Event-driven Programming Selection Screen. Event-driven Programming. Application Driven Programming. REPORT ztest. DATA: today TYPE D. today = ‘19991231’. today = today + 1. WRITE: / today. Event-Driven Programming. Data tmp type i. Start-of-Selection.

sasson
Télécharger la présentation

ABAP Chapter 4

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 Chapter 4 • Event-driven Programming • Selection Screen

  2. Event-driven Programming

  3. Application Driven Programming • REPORT ztest. • DATA: today TYPE D. • today = ‘19991231’. • today = today + 1. • WRITE: / today.

  4. Event-Driven Programming Data tmp type i. Start-of-Selection. Write: / ‘This is ’. Write: / ‘Basic List’. At line-selection. Write: / ‘This is ’. Write: ‘Detail List’.

  5. Events • START-OF-SELECTION. • END-OF-SELECTION. • TOP-OF-PAGE. • TOP-OF-PAGE DURING LINE-SELECTION. • END-OF-PAGE. • AT LINE-SELECTION. • AT USER-COMMAND. • INITIALIZATION. • AT SELECTION-SCREEN.

  6. AT LINE-SELECTION Event(Drill-down Report)

  7. AT LINE-SELECTION Start-of-selection. Write : ‘Basic List’. At Line-selection. Write : ‘Detail List’. Basic list Double Click

  8. Navigating Between Lists Detail list 20 Exit Detail list 2 ABAP Editor Detail list 1 Cancel Basic list Back

  9. Detail List and SY-LSIND Detail list 2 SY-LSIND = 2 Start-of-selection. write: ‘Basic List’. AT Line-selection. CASE sy-lsind. WHEN 1. write: ‘Detail List #1’. WHEN 2. write: ‘Detail List #2’. ENDCASE. Detail list 1 SY-LSIND = 1 Basic list

  10. At Line Selection Tables customers. Start-of-Selection. Select * from customers. write : / customers-name . Endselect. At line-selection. Write: ‘You Choose :’ , customers-name.

  11. At Line Selection(Hide Statement) List Buffer Tables customers. Start-of-Selection. Select * from customers. write : / customers-name. Hide customers-name. Endselect. At line-selection. Write: ‘You Choose :’ , customers-name. John Peter David HIDE area of list level 1 line Field name Value 1 customers-name John 2 customers-name Peter 3customers-name David

  12. Customers Structure 3 | David | .... HIDE area of list level 1 line Field name Value 1 customers-name John 2 customers-name Peter 3customers-name David Hide Area in List • Dialog WP Local Memory Application Server Memory Space TaskHandler ABAP Processor Listbuffer DYNPRO Processor Basic List John Peter David DB Interface Result Set Memory Database Server Database

  13. At Line Selection(Hide Statement) Detail List Basic List You choose : Peter John Peter David 5 At Line-selection 1 SY-LILLI = 2 4 HIDE area of list level 1 line Field name Value 1 customers-name John 2 customers-name Peter 3customers-name David Customers Structure 2 3 | Peter | .... 3

  14. At Line Selection(Hide Statement) List Buffer Tables customers. Start-of-Selection. Select * from customers. write : / customers-id,customers-name. Hide:customers-id,customers-name. Endselect. At line-selection. Write: ‘You Choose :’ , customers-id, customers-name. 00000001 John 00000002 Peter 00000003 David HIDE area of list level 1 line Field name Value 1 customers-id 00000001 1 customers-name John 2customers-id 00000002 2customers-name Peter …

  15. At Line Selection(Hide Statement) Detail List Basic List You choose : 00000002 Peter 00000001 John 00000002 Peter 00000003 David 5 At Line-selection 1 SY-LILLI = 2 4 HIDE area of list level 1 line Field name Value … … … 2 customers-id 00000002 2 customers-name Peter 3customers-id 00000003 … Customers Structure 2 2 | Peter | .... 3

  16. At Line Selection Basic List (SPFLI) Tables: spfli,sflight. Start-of-selection. Select * from spfli. write : / spfli-carrid, spfli-connid, spfli-cityto. Hide : spfli-carrid, spfli-connid. Endselect. At Line-selection. select * from sflight where carrid = spfli-carrid and connid = spfli-connid. write: / spfli-carrid, spfli-connid,sflight-fldate. endselect. Detail List (SFLIGHT)

  17. Exercise Basic List zcustomers-id Detail List zcustomers zcustomers-name zsales-cust_id zsales-qty zsales-prod_id zsales

  18. Hide Statement (Report Heading) List Buffer Tables customers. Top-of-page. write: / ‘Customers Name’. uline. Start-of-Selection. Select * from customers. write : / customers-name. Hide customers-name. Endselect. At line-selection. Write: ‘You Choose :’ , customers-name. Customers Name ----------------------------- John Peter David HIDE area of list level 1 line Field name Value 3 customers-name John 4 customers-name Peter 5customers-name David

  19. At Line Selection(Hide Statement) Detail List Basic List You choose : Peter Customers Name ----------------------------- John Peter David 5 At Line-selection 1 SY-LILLI = 4 4 HIDE area of list level 1 line Field name Value 3 customers-name John 4 customers-name Peter 5customers-name David Customers Structure 2 3 | Peter | .... 3

  20. Invalid Line Selection … TOP-OF-PAGE. … Hide: spfli-carrid, spfli-connid. … Endselect. Clear: spfli-carrid,spfli-connid. At Line-selection. Select * From sflight Where carrid = spfli-carrid and connid = spfli-connid. Write: / spfli-carrid, spfli-connid ,sflight-fldate. Endselect. Clear: spfli-carrid,spfli-connid.

  21. Page Heading Start-of-selection. Write: ‘Basic List’. At Line-selection. Write: ‘Detail List’. Top-of-page. Write: ‘Header-Basic List’. Top-of-page During Line-selection. Write: ‘Header-Detail List’.

  22. Detail List Page Heading ... top-of-page during line-selection. case sy-lsind. when 1. write: / ‘Detail List Header #1’. when 2. write: / ‘Detail List Header #2’. endcase. ..... .....

  23. Column Selection ... data: fieldname(30). ... start-of-selection. select * from spfli. write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto. hide: spfli-carrid,spfli-connid. endselect. at line-selection. case sy-lsind. when 1. get cursor field fieldname. case fieldname. when 'SPFLI-CARRID'. select single * from scarr where carrid = spfli-carrid. if sy-subrc = 0. write: / spfli-carrid,scarr-carrname. endif. when 'SPFLI-CONNID'. select * from sflight where carrid = spfli-carrid and connid = spfli-connid. ...

  24. Column Selection : Value ... data: fieldname(30),fieldvalue(30). ... start-of-selection. select * from spfli. write: / spfli-carrid,15 spfli-connid, 25 spfli-cityto. hide: spfli-carrid,spfli-connid. endselect. at line-selection. case sy-lsind. when 1. get cursor field fieldname value fieldvalue. case fieldname. when 'SPFLI-CARRID'. select single * from scarr where carrid = spfli-carrid. if sy-subrc = 0. write: / spfli-carrid,scarr-carrname. endif. when 'SPFLI-CONNID'. ...

  25. Creating List in Modal Dialog Box ... at line-selection. window starting at 10 10 ending at 65 20. select * from sflight where carrid = spfli-carrid and connid = spfli-connid. write: / sflight-carrid,sflight-connid,sflight-fldate. endselect. ...

  26. Exercise Basic List zsales zsales-qty zsales-cust_id zsales-prod_id zsales-sale_id Detail List zsalereps zproducts zproducts-on_hand zproducts-p_id zsalereps-sale_id zsalereps-name

  27. Drill-Down 2 Levels Example Detail list level 2 (ZPRODUCTS) 2 Basic list (ZCUSTOMERS) 1 Detail list level 1 (ZSALES)

  28. Program Example START-OF-SELECTION. SELECT * FROM zcustomers. WRITE: / zcustomers-id COLOR 4 HOTSPOT, 15 zcustomers-name. HIDE: zcustomers-id,zcustomers-name. ENDSELECT. CLEAR zcustomers-id. AT LINE-SELECTION. CASE sy-lsind. WHEN 1. GET CURSOR FIELD fieldname. IF fieldname = 'ZCUSTOMERS-ID'. SELECT * FROM zsales WHERE cust_id = zcustomers-id. IF sy-dbcnt = 1. WRITE: / zcustomers-id,15 zcustomers-name,30 zsales-prod_id HOTSPOT, 45 zsales-qty. HIDE: zsales-prod_id. ELSE. WRITE: /30 zsales-prod_id HOTSPOT, 45 zsales-qty. HIDE: zsales-prod_id. ENDIF. ENDSELECT. CLEAR: zcustomers-id,zsales-prod_id. ENDIF. WHEN 2. GET CURSOR FIELD fieldname. IF fieldname = 'ZSALES-PROD_ID'. SELECT SINGLE * FROM zproducts WHERE p_id = zsales-prod_id. IF sy-subrc = 0. WRITE: / zproducts-p_id,15 zproducts-prod_name,38 zproducts-on_hand. ENDIF. CLEAR zsales-prod_id. ENDIF. ENDCASE. Hide Level 1 Drill Down Level 1 Hide Level 2 Drill Down Level 2

  29. Exercise Basic List SCARR Drill-down Level 1 SPFLI Drill-down Level 2 SFLIGHT Drill-down Level 3 SBOOK

  30. GUI Interface (User Interface)

  31. GUI Interface SET PF-STATUS …. => GUI Status SET TITLEBAR …. => GUI Title

  32. AT USER-COMMAND Event SET PF-STATUS ‘TEST’. ... AT USER-COMMAND. CASE sy-ucomm. WHEN ‘CODE1’. . WHEN ‘CODE2’. . ENDCASE.

  33. Standard Toolbar : System Function • System function do not trigger event AT USER-COMMAND • %EX = Exit • %PC = Save to file • %SC = Find • %SC+ = Find next • %ST = Save in report tree • BACK = Back • RW = Cancel • PRI = Print • P- = Scroll to previous page • P-- = Scroll to first page • P+ = Scroll to next page • P++ = Scroll to last page

  34. Alternative with AT USER-COMMAND REPORT ZRSDEM002. . START-OF-SELECTION SET PF-STATUS ‘BASE’. . . AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘CARR’. SET PF_STATUS SPACE. “Set to standard GUI interface . WHEN ‘FLIG’. SET PF-STATUS ‘FLIG’. WRITE … . .

  35. GUI Status Excluding Function Code REPORT ztest. ... SET PF-STATUS ‘0100’. ... AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘LIST’. SET PF-STATUS ‘0100’ excluding ‘LIST’. . WHEN ‘DISP’. SET PF-STATUS ‘0100’ excluding ‘DISP’. WRITE … . ....

  36. GUI Status Excluding Function Code REPORT ztest. DATA exctab(10) occurs 0 with header line. .... START-OF-SELECTION. SET PF-STATUS ‘0100’. ... exctab = ‘LIST’. APPEND exctab. exctab = ‘TEST’. APPEND exctab. ... AT USER-COMMAND. CASE SY-UCOMM. WHEN ‘LIST’. SET PF-STATUS ‘0100’ excluding exctab.

  37. GUI TITLE ... SET TITLEBAR ‘0100’.

  38. ABAP Practice

  39. Selection Screen

  40. Selection Screen • PARAMETERS Statement • SELECT-OPTIONS Statement

  41. parameters

  42. Parameters PARAMETERS: tmp1(10)TYPE C, tmp2(10) TYPE C lower case, tmp3 LIKEsy-datumdefault sy-datum, tmp4 TYPE Ddefault ‘19991231’, tmp5 TYPEi, tmp6(5) TYPE N.

  43. Parameters Example Tables customers. Parameters pid like customers-id. START-OF-SELECTION. select single * from customers where id = pid. if sy-subrc = 0. write: / customers-name. else. write: / ‘No data found’. endif.

  44. Selection-Text • By default , the System displays the name of the selection as text on the Selection Screen • You Should use the Text element/Selection texts function to store a text line for each Selection Criterion.

  45. Check box Parameters tmp as checkbox default ‘X’.

  46. Radio Button Parameters: test1 Radiobutton group grp1, test2 Radiobutton group grp1.

  47. Required field with Parameters Parameters tmp like sy-datum obligatory.

  48. ABAP Exercise

  49. select-options

  50. Complex Selection (Select-options) Tables spfli. Select-options carrid for spfli-carrid. START-OF-SELECTION. Select * From spfli Where carrid in carrid. . . . Endselect.

More Related