Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

This document is written to shown step by step guide to configure news app in Fiori. In all, there are three steps:

  1. Configure Fiori title
  2. Create Table to store news information
  3. Generate SICF service and provide RSS 2.0 format

Step one: Configure Fiori title

Click on News Tile

Fill in SICF service name in the Feed, Article Refresh Interval means the refresh interval of news apps. Prefer to set to 15min.

SICF service name: znews (which will later be created)

Step two: Create a Table to store news information

This table should contain all essential information needed for news.

Step three: Generate SICF service and provide RSS 2.0 format

For the news app itself we need to provide RSS document.

Please refer XML RSS for the principle of RSS 2.0.

We create a SICF service called znews to generate this kind of RSS document (This is the service name you bind in Step one).

Create a class called ZCL_NEWS_SERVICE. Fill in IF_HTTP_EXTENSION in Interface.  Fill below code in IF_HTTP_EXTENSION~HANDLE_REQUEST.  Check and active this class. 

1

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

  method IF_HTTP_EXTENSION~HANDLE_REQUEST.

    DATA action TYPE STRING .

    DATA xmlcstr TYPE STRING .

    DATA newscontent TYPE TABLE OF ZNEWSCONTENT.

    DATA newscontent_l LIKE LINE OF newscontent.

    DATA guidstr TYPE STRING.

    DATA titlestr TYPE STRING.

    DATA descriptionstr TYPE C LENGTH 400.

    DATA imagestr TYPE STRING.

    DATA linkstr TYPE STRING.

    action = server->request->get_form_field( name = 'type' ).

    CASE action.

      WHEN 'news'.

        SELECT * FROM ZNEWSCONTENT INTO TABLE newscontent.

        xmlcstr = '<?xml version="1.0" encoding="utf-8"?><rss version= "2.0"> <channel>'.

        LOOP AT newscontent INTO newscontent_l.

CLEAR: guidstr, titlestr, descriptionstr, imagestr, linkstr.

          CONCATENATE xmlcstr '<item>' INTO xmlcstr.

          guidstr = newscontent_l-guid.

          titlestr = newscontent_l-title.

          descriptionstr = newscontent_l-description.

          imagestr = newscontent_l-imagelink.

          linkstr = newscontent_l-contentlink.

          CONCATENATE xmlcstr '<guid>' guidstr '</guid>'

                              '<title>' titlestr '</title>'

'<description>' descriptionstr '</description>'

                              '<image>' imagestr '</image>'

                              '<link>' linkstr '</link>' INTO xmlcstr.

         CONCATENATE xmlcstr '</item>' INTO xmlcstr.

       ENDLOOP.

       CONCATENATE xmlcstr '</channel></rss>' INTO xmlcstr.

server->response->set_header_field(

       name = 'Content-Type'

       value = 'application/xml' ).

server->response->set_header_field(

       name = 'accept-origin'

       value = '*' ).

       server->response->set_cdata( data = xmlcstr ).

    ENDCASE .

  endmethod.

Run traction SICF.

In path default_host/sap/bc, right click on bc and choose New Sub-Element. Fill in your SICF service name.

Fill in a description and Handler List, leave other as default.

Check and Active this service.

You can have a test the SICF service now. Right click on the service name and click Test Service.

Also if you have configure the Fiori Launchpad correct, you can see the real news app.

12 Comments