Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

How to configure Fiori News App by using SICF service and RSS2.0

$
0
0

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

1.png

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)

1.png

 

Step two: Create a Table to store news information

This table should contain all essential information needed for news.

1.png

 

Step three: Generate SICF service and provide RSS 2.0 format

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

Please refer http://www.w3school.com.cn/rss/rss_syntax.asp 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.png

 

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.

1.png

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

1.png

Check and Active this service.

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

1.png

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

1.png

2.PNG


Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>