Quantcast
Channel: ABAP Development
Viewing all 948 articles
Browse latest View live

Blog It Forward - Susmitha Susan Thomas

$
0
0

I was blogged forward by Mohammed Yakub Shah and Arindam Mondal. Thanks to you for letting me participate in this innovative and exciting game of 'passing the baton' in SCN and thanks to Moshe Naveh for this wonderful initiative. I am glad I could be a link to keep this chain growing even a year (to be exact 1 year and three days ) after it was created.

 

About Me:

 

I am an SAP Consultant working in Gulf Piping Company, Abu Dhabi, UAE. Previously I was working with Wipro Technologies, Bangalore. I did not chose SAP. I was randomly put in the SAP batch among the campus recruited students batches in Wipro, for which I am very grateful to God. Coz I thoroughly love SAP and ABAP programming and am not sure if I would have enjoyed anything else as much.

 

It was only in the last one year that I started becoming active in SCN, the gamification definitely played a role initially, but then it slowly moved to that satisfaction you get in being able to help someone solve some problem in addition to the excitement of solving puzzling situations.

 

In the company I am working, I am the only SAP ABAP Consultant, and I used to feel a little lonely when it comes to SAP and ABAP but once I was active in SCN, I never felt alone : Felt I was part of an SAP family with many friends to share the experiences in SAP and ABAP. 

 

SCN soon became a part of my daily routine and if I open my browser, you can bet an SCN tab would be opened.

 

 

About my Home Land :

 

I was born in the southern most state in India, called Kerala, often known as God's Own country. Kerala is one of the most beautiful places and is a very popular tourist destination.

 

Its beauty is mostly contributed by back waters, long shoreline with serene beaches, paddy fields, waterfalls and wild life.

 

backwater  alleppey.jpg

 

 

 

 

index1.jpg

                                                                                                                 index.jpgxKerala-Tourism-Banner.jpg.pagespeed.ic.ccj9D-hCz2.jpg

A few facts about Kerala : Kerala is the state which has the highest Human Development Index (HDI) (0.790) in the country, highest literacy rate (almost 100%), the highest life expectancy (74 years) and the highest *** ratio (as defined by number of women per 1000 men: 1,083 women per 1000 men) among all Indian states. Malayalam is the most widely and official language spoken in Kerala.

 

Questions Asked :


  1. What are the best experiences that you had while being part of this community?I enjoy every moment in SAP. As mentioned before, the thrill of solving issues, is one of the best experiences : that moment when you know that your solution solved a problem, and to know that it saved someone's day makes it even more better.
  2. What are the hobbies or activities that you enjoy most? Music Music Music. I love listening to music and playing music. I can sit for hours and hours and hours on my guitar, violin and piano.
  3. What would you be if not an SAP Consultant ? - Financial and Stock Market Analyst.
  4. What was the most fun project you ever participated in and why? - It was a chatting application that we friends created in college. The amount of fun that was we used to have by chatting with the friends sitting in the same room under the noses of our lecturers was some fun. :-)


I would like to pass the baton to

Frédéric Girod

Ramesh T

Raymond Giuseppi

 

My questions to you..

  • What was your dream job as a kid?
  • Who has inspired and motivated you the most?
  • What is the most important quality that you hope to find in your colleague that will make your work place a better place?

 

To know more about BIF, refer this blog. Blog It Forward Community Challenge. Once you complete the BIF, update your details in the BIF chain -

Blog It Forward Chain

 

Regards.

Susmitha




Example for cell colors in ALV

$
0
0

HereI attachedan examplequite usefulto knowthe differentcell colorswe can giveto aALV.


 

 

*&---------------------------------------------------------------------*
*& Report  ZCELL_COLORS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZCELL_COLORS.

TYPES:
   BEGIN OF ts_data,
     col   TYPE lvc_col,    " color 1-7
     int   TYPE lvc_int,    " intensified 0-1
     inv   TYPE lvc_inv,    " inverse 0-1
     scol  TYPE lvc_t_scol, " table for cell coloring
   END OF ts_data,
   tt_data TYPE TABLE OF ts_data.

DATA:
   ls_data    TYPE ts_data,
   lt_data    TYPE tt_data,
   lv_index   TYPE i,
   ls_color   TYPE lvc_s_scol,
   lt_color   TYPE lvc_t_scol,
   lo_table   TYPE REF TO cl_salv_table,
   lo_columns TYPE REF TO cl_salv_columns_table,
   lo_column  TYPE REF TO cl_salv_column_list.

* empty row with default color
APPEND ls_data TO lt_data.

* rows with possible colors
DO 7 TIMES.

   ls_color-color-col = sy-index.   " 1-7

   DO 2 TIMES.

     lv_index = sy-index - 1.
     ls_color-color-int = lv_index.   " 0-1

     DO 2 TIMES.

       lv_index = sy-index - 1.
       ls_color-color-inv = lv_index.   " 0-1

       APPEND ls_color TO lt_color.

       ls_data-col   = ls_color-color-col.
       ls_data-int   = ls_color-color-int.
       ls_data-inv   = ls_color-color-inv.

       ls_data-scol = lt_color.
       APPEND ls_data TO lt_data.
       CLEAR lt_color.
     ENDDO.
   ENDDO.
ENDDO.

TRY.
     CALL METHOD cl_salv_table=>factory
       IMPORTING
         r_salv_table = lo_table
       CHANGING
         t_table      = lt_data.

     lo_columns = lo_table->get_columns( ).

*   set descriptions of columns
     lo_column ?= lo_columns->get_column( 'COL' ).
     lo_column->set_short_text( 'COL' ).

     lo_column ?= lo_columns->get_column( 'INT' ).
     lo_column->set_short_text( 'INT' ).

     lo_column ?= lo_columns->get_column( 'INV' ).
     lo_column->set_short_text( 'INV' ).

*   set the column with the information about colors of rows and fields
     lo_columns->set_color_column( 'SCOL' ).

     lo_table->display( ).

   CATCH cx_salv_msg.             " cl_salv_table=>factory
     WRITE: / 'cx_salv_msg exception'.
     STOP.

   CATCH cx_salv_data_error.      " cl_salv_filters->add_filter()
     WRITE: / 'cx_salv_data_error'.
     STOP.

   CATCH cx_salv_not_found.       " cl_salv_columns_table->get_column()
     WRITE: / 'cx_salv_not_found exception'.
     STOP.
ENDTRY.

*------------------------------------------------

 

Regards.


Change Word table style in an Open XML document

$
0
0

Hello.

This  is another screen cast about the Open XML in SAP.

this one dealing with layout change of the MS-Word template

without any  programming changes.

it shows  how  a  change int the table style can  change the layout

of the document.

 

 

 

http://youtu.be/oJOXJ7xXWk0

 

 

 

Open XML documents are manipulated on the SAP server

without using  MS-Word application.

 

 

 

   Ronen Almog

Open XML for SAP ver. SAP Duet

$
0
0

Hello.

I've been asked in  the last few months  about Open XML for SAP.

some of the people compared it to SAP duet

some of them said that Duet does the same functions as Open XML does.

well, i'm not an expert of Duet, but i did some research  about it and find out

that there is no common between the two.

 

Open XML for SAP  ( Office 4 Sap  )  does  creation and manipulation of Office documents and spreadsheets

on  the SAP server, Duet is an Interface between SAP and SharePoint server.

 

Open XML for SAP uses the Open XML  standards while Duet uses Odata Channel.

 

If you have any need for Office documents and spreadsheets manipulation

consider the use of Open XML for SAP.

 

 

   Cheers

 

    Ronen Almog

Get the data types of all fields in a table

$
0
0

Hello everyone,

 

After some research I've managed to find an answer to my own question here:

http://scn.sap.com/thread/3412096

and I would like to share this with you.

Basically, in oder to find the types of all fields of a given table, just make the following query to table DD03L:

SELECT tabname fieldname rollname

     INTO TABLE some_table

     FROM DD03L

     WHERE tabname = some_name.

 

BUT, sometimes, fields might be either a structure, or a table as well (deep table\structure). In those cases, we need to select the field type from tables DD03M (if structure) or DD40L (if table). Here are examples:

SELECT typename rowtype

     INTO TABLE some_other_table

     FROM DD40L

     WHERE typename = some_row_from_some_table-rollname.

OR

SELECT tabname fieldname rollname domname

     INTO TABLE some_other_different_table

     FROM DD03M

     WHERE tabname = some_row_from_some_table-rollname.

 

Note the differences between the two queries.

 

Any additions, corrections, or maybe a name of an existing function that does all that faster and easier, will be appericiated!

Hope that helps someone

Blog if forward - Ramesh.T

$
0
0

I was blogged forward by Susmitha Susan Thomas and Frédéric Girod, Thank you for this opportunity to me participate in this exciting game of 'passing the baton' in SCN and thanks to Moshe Naveh for this wonderful initiative.

 

About Me:


I am an SAP Consultant working in Lanco, Andhra Pradesh, India. With SAP my association last 7 years, after completing my education I joined in Lanco, at that time I don’t know about SAP. After joining, my company started SAP implementation. During implementation I got opportunity to learn SAP ABAP and I continued as ABAP Consultant. I love SAP and ABAP Programming.


Association with SCN for last five months, I enjoying a lot with SCN when giving solutions, someone makes my answer as correct and getting solution. Before SCN I feel alone in my job, now I was part of an SAP family with many friends to share the experiences in SAP and ABAP. I always thankful to Matthew Billingham for showing me a right path. Now SCN become part of my life.

 


 

About my Home Land :


I was born in Andhra Pradesh, India; Andhra Pradesh is india’s fourth largest state by area and fifth largest state by population, our capital Hyderabad,  Andhra Pradesh is bordered by Maharashtra, Chhattisgarh and Orissa in the north, the Bay of Bengal in the east, Tamil Nadu to the south and Karnataka to the west.


It is historically called the "Rice Bowl of India".More than 77% of its crop is rice; Andhra Pradesh produced 17,796,000 tonnes (19,616,732 short tons) of rice in 2006. Two of the mega cities of the state - Hyderabad and Visakhapatnam - were listed among the top 15 cities contributing to India's overall Gross domestic product. On 1 November 1956, the States Reorganisation Act formed Andhra Pradesh by merging the Andhra State with the Telugu-speaking areas of already existing Hyderabad State.

 

 

 

 

 

Questions Asked :

  • What was your dream job as a kid?

            Scientist like Albert Einstein 

  • Who has inspired and motivated you the most?

            My Parents

  • What is the most important quality that you hope to find in your colleague that will make your work place a better place?         

            I feel team work on resolving critical issues, helping nature on helping other’s when

            they are facing problems and try to learning new things.   

 

 

I would like to pass the baton to

Raymond Giuseppi

Matthew Billingham

Smruti Ranjan Mohanty

 

My questions to you..

  • What quality’s required to be a good ABAP Programmer.
  • Had you not been into software at all, where would you have been?
  • What is your best moment in life?
  • Who has inspired and motivated you the most?

 

To know more about BIF, refer this blog. Blog It Forward Community Challenge. Once you complete the BIF, update your details in the BIF chain - Blog It Forward Chain

 

Once again tanks to all for giving this opportunity..


Regards,

Ramesh.T

Things to be taken care on creating custom Check printing in SAP – SAP Script F110_PRENUM_CHCK

$
0
0
  1. Create a custom copy of F110_PRENUM_CHCK
  2. Create a subroutine pool in SE38, to achieve
    logic changes in the SAP Script even without modifying the standard driver
    program RFFOUS_C
  3. While commenting existing standard scripts, make
    sure that the mentioned element should not get deleted, even though you are not
    going to display anything under this element. Instead you can add one commented
    text under the respective elements.
  4. Say for example, if you need to display the
    remittance section as a table, then it is always a good practice to keep the
    BOX comments for drawing lines in the main window as one separate window. The
    following is some example code to draw a table with Five columns:

 

           Vertical Lines

 

/:           BOX XPOS 0 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

/:           BOX XPOS 27 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

/:           BOX XPOS 70 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

/:           BOX XPOS 113 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

/:           BOX XPOS 149 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

/:           BOX XPOS 192 MM YPOS 0 MM WIDTH 0 TW HEIGHT 138 MM FRAME 10 TW

 

          Horizontal Lines

 

/:           BOX YPOS 0 MM WIDTH 192 MM HEIGHT 0 TW FRAME 10 TW

/:           BOX YPOS 10 MM WIDTH 192 MM HEIGHT 0 TW FRAME 10 TW

 

          Sum total Row

/:           BOX YPOS 130 MM WIDTH 192 MM HEIGHT 0 TW FRAME 10 TW

/:           BOX YPOS 138 MM WIDTH 192 MM HEIGHT 0 TW FRAME 10 TW

 

 

    5.   For putting frame to a window, we can use thefollowing:

 

/:           BOX FRAME 30 TW

How to create a RoadMap in GUI environment

$
0
0

Hi guys,

 

This is my first blog and I found an interesting subject one week ago about RoadMap but in GUI environment, normally Roadmap is used with Web Dynpros.

 

This is the code of my program

 

*---------------------------------------------------------------------*
 * Description                                                                    *
 *--------------------------------------------------------------------*
 * Program      : YTEST_ROADMAP                               *
 * Author          : David Carballido Córdova                   *
 * Date             : 22/08/2013                                              *
 * Comentarios   : Build and show Roadmap             *
 *--------------------------------------------------------------------*
 REPORT ytest_roadmap.

 PARAMETERS: p_steps TYPE i OBLIGATORY.
 *----------------------------------------------------------------------*
 *       CLASS DEFINITION DEFERRED
 *----------------------------------------------------------------------*
 CLASS: lcl_main  DEFINITION DEFERRED,        lcl_event DEFINITION DEFERRED.

 *----------------------------------------------------------------------*
 *       Global Variables
 *----------------------------------------------------------------------*
 DATA: go_main TYPE REF TO lcl_main,       g_state TYPE /use/ugu1_state,       g_text  TYPE char40.

 *----------------------------------------------------------------------*
 *       CLASS lcl_main DEFINITION
 *----------------------------------------------------------------------*
 CLASS lcl_main DEFINITION FINAL.   PUBLIC SECTION.     METHODS: start_road,              state_click IMPORTING i_state_id TYPE /use/ugu1_state,              next_step.   PRIVATE SECTION.     METHODS: init_roadmap.     DATA: go_roadmap TYPE REF TO /use/cl_ugu1_html_roadmap,           go_custom  TYPE REF TO cl_gui_custom_container,           go_event   TYPE REF TO lcl_event.

 ENDCLASS.                    "lcl_main DEFINITION

 *----------------------------------------------------------------------*
 *       CLASS lcl_event DEFINITION
 *----------------------------------------------------------------------*
 CLASS lcl_event DEFINITION FINAL.   PUBLIC SECTION.     METHODS: state_click FOR EVENT evt_state_click                 OF /use/cl_ugu1_html_roadmap                     IMPORTING i_state_id.

 ENDCLASS.                    "lcl_event DEFINITION

 *----------------------------------------------------------------------*
 *       CLASS lcl_main IMPLEMENTATION
 *----------------------------------------------------------------------*
 CLASS lcl_main IMPLEMENTATION.   METHOD start_road.     IF go_custom IS INITIAL.
* Instance Container       CREATE OBJECT go_custom         EXPORTING           container_name              = 'ROADMAP'         EXCEPTIONS           cntl_error                  = 1           cntl_system_error           = 2           create_error                = 3           lifetime_error              = 4           lifetime_dynpro_dynpro_link = 5.       IF sy-subrc = 0.
* Instance Roadmap         CREATE OBJECT go_roadmap           EXPORTING             i_parent            = go_custom             i_application_event = abap_true           EXCEPTIONS             cntl_error          = 1.         IF sy-subrc <> 0.           EXIT.         ENDIF.
* Instance Event Class         CREATE OBJECT go_event.         SET HANDLER go_event->state_click FOR go_roadmap.
 *  Initializing Roadmap         me->init_roadmap( ).
 * Set  Width of Roadmap         go_roadmap->set_state_width( i_width = '40' ).
 * Generate HTML of Roadmap         go_roadmap->render( EXCEPTIONS render_error = 1 ).       ELSE.         EXIT.       ENDIF.     ENDIF.   ENDMETHOD.                    "start_road   METHOD init_roadmap.
 * Local Variables     DATA: l_step TYPE numc2,           l_text TYPE char30.
* Initializing States     go_roadmap->remove_all_states( EXCEPTIONS remove_failure = 1 ).     DO p_steps TIMES.       l_step = sy-index.       CONCATENATE 'Step' l_step INTO l_text SEPARATED BY space.       go_roadmap->add_state(         EXPORTING           i_state_text   = l_text           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_normal           i_is_clickable = abap_true           i_is_optional  = abap_false         EXCEPTIONS           add_failure    = 1 ).     ENDDO.
 * Activate first state     IF g_state IS INITIAL.       go_roadmap->set_state_type(         EXPORTING           i_state_id     = '1'           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_active         EXCEPTIONS           invalid_state  = 1           update_failure = 2 ).
 * Send initial text       g_text = go_roadmap->get_state_text( '1' ).     ELSE.       go_roadmap->set_state_type(         EXPORTING           i_state_id     = g_state           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_active         EXCEPTIONS           invalid_state  = 1           update_failure = 2 ).     ENDIF.   ENDMETHOD.                    "init_roadmap   METHOD state_click.     g_state = i_state_id.
 * Get text of state      g_text = go_roadmap->get_state_text( i_state_id ).
 * Free Objects     go_roadmap->free( ).     go_custom->free( ).
 * Clean Objects     CLEAR: go_roadmap, go_custom.
 * Simulate ENTER to refresh screen     cl_gui_cfw=>set_new_ok_code( '/00' ).   ENDMETHOD.                    "state_click   METHOD next_step.
 * Local Variables     DATA: lt_states TYPE /use/ugu1_t_roadmap_state,           l_state   TYPE /use/ugu1_state.     FIELD-SYMBOLS: <fs_states> TYPE /use/ugu1_s_roadmap_state.
 * Get active state     go_roadmap->get_states_by_type(       EXPORTING         i_state_type = /use/cl_ugu1_html_roadmap=>c_state_active       IMPORTING         et_states = lt_states ).     READ TABLE lt_states ASSIGNING <fs_states> INDEX 1.     IF sy-subrc = 0.       l_state = <fs_states>-state_id + 1.
 * Get residue on parameter selected       l_state = l_state MOD ( p_steps + 1 ).       IF l_state = 0.         l_state = 1.       ENDIF.
 * Set state click       me->state_click( l_state ).     ELSE.       MESSAGE s888(sabapdocu) WITH 'No existe paso activo'.     ENDIF.   ENDMETHOD.                    "next_step
 ENDCLASS.                    "lcl_main IMPLEMENTATION

 *----------------------------------------------------------------------*
 *       CLASS lcl_event IMPLEMENTATION
 *----------------------------------------------------------------------*
 CLASS lcl_event IMPLEMENTATION.   METHOD state_click.     go_main->state_click( i_state_id ).   ENDMETHOD.                    "state_click

 ENDCLASS.                    "lcl_event IMPLEMENTATION

 *----------------------------------------------------------------------*
 *       S T A R T  -  O F  -  S E L E C T I O N
 *----------------------------------------------------------------------*
 START-OF-SELECTION.
 * Instance Main Class   CREATE OBJECT go_main.
 * Show Roadmap   CALL SCREEN 100.

 *&---------------------------------------------------------------------*
 *&      Module  STATUS  OUTPUT
 *&---------------------------------------------------------------------*
 MODULE status OUTPUT.   SET PF-STATUS 'ST_100'.   SET TITLEBAR 'TIT_100'.
 * Show Roadmap   go_main->start_road( ).

 ENDMODULE.                 " status  OUTPUT

 *&---------------------------------------------------------------------*
 *&      Module  user_command  INPUT
 *&---------------------------------------------------------------------*
 MODULE user_command INPUT.   CASE sy-ucomm.     WHEN 'BACK'.       LEAVE TO SCREEN 0.     WHEN 'NEXT'.       go_main->next_step( ).   ENDCASE.

 ENDMODULE.                 " user_command  INPUT

 

Here I attach screen 100 to upload and generate

Dynpro_1.jpg

Dynpro_2.jpg

Then when you execute the program you can select how many steps are going to build, for example I'll select 10

Dynpro_3.jpg

And this is the result

Dynpro_4.jpg

You can click on any step or press "Next Step" button to select the next step, I hope this help you in any development and I welcome your comments

 

PD: Sry for my bad english

 

Regards

David Carballido


ABAP Adventure Games Framework - Part 1 - "Introduction"

$
0
0

Yes, you read it right: this blog is about ABAP and Games. I know a few people already implemented their own games using ABAP, but I always felt I also had to make a little contribution into this area. In fact, I tried doing a "contribution" by myself, but something happened along the way and I had to change my plans. In this blog I'll tell you what happened, what are my ideas, and how you can help along the way.

 

 

AS Trial Nightmares

 

Before explaining my motivations for doing an adventure game, I must say I already made this game framework using ABAP, in 2011.  But one pretty day I started my AS Trial VM and got to know that my MaxDB got corrupted, and I lost everything I had inside my AS Trial installation. I made that classical error of not backing up my sources outside the SAP system, and I got extremely mad about it. I even presented my game at the SAP Inside Track São Paulo we had in 2011, so you can imagine how nervous I got about my dumb mistake.

 

The only thing I have left of that prototype is a video I made for my own ABAP blog:

 

(it's brazilian portuguese, but you can get the idea)

 

I want to make that game again, but this time I do not want to make it all by myself. That's why I'm writing this blog: I want to get help from the community!

I'm a huge fan of OO developments, but I'm far away from being an expert. Hopefully this crazy idea can raise good discussions about software architecture, development practices and OO concepts, making me (and maybe you!) a better developer when things are finished.

 

Ready? Let the game begin!

 

 

1. Motivation

 

"Man, are you nuts? Making an ABAP game with old and ugly 'WRITE reports' when we have things like HANA, UI5, SUP, bla, bla, bla, bla?".

 

My first contact with computers were through DOS games. I remember getting extremely excited whenever my father said we were going to my grandmother's house, because I knew I would get a change of playing a game in my aunt's "bright new" 486 computer ( yeap, she was always very cool to all of her nephews). One of my siblings got a friend who could install games using 20 (or something) floppy disks, and every couple of months he came and added a few gems to my aunt's game library. That's how I got to know Warcraft, Doom, Castle Wolfenstein and Hexen.

 

But then I played a game that made me crazy about that genre until today. It all started with a little purple tentacle trying to dominate the whole world:

 

http://upload.wikimedia.org/wikipedia/en/thumb/7/79/Day_of_the_Tentacle_artwork.jpg/250px-Day_of_the_Tentacle_artwork.jpg

I still finish this game every couple of years, using scummvm

 

 

How the game works: you got some "actions" in the bottom side of the screen,, and you move forward in the game by talking to NPCs, finding new areas, combining items and using them at the right places. The NPC characters always give you clues about what you have to do next... however, can you imagine how hard it was for a 11 years old brazilian boy to solve those puzzles? As you are seeing (or reading?) I'm not a native english speaker/writer, and I didn't even know what english was about back in those days. Basically I used a lot of my time trying to do every little combination I could to advance. I'm not sure why I just didn't drop it and went back to Doom, but I guess some things are not meant to be explained.

 

Then I played things like Monkey Island, Indiana Jones and The Fate of Atlantis, Loom, Sam & Max... and I kept playing this kind of stuff until today, and the odds are I'll never stop loving this game genre (btw, try playing Machinarium it's EXTREMELY AWESOME!).

 

So every since I started programming, I always wanted to make an Adventure Game. Now, I could use some new and fancy stuff to implement this idea, but it's not about being opposite to new tools and products, it's more about gaming retro-style. Also, ABAP lists are surely *not* made for animated stuff, so it's kinda fun to overcome those limitations.

 

 

2. Framework

 

You understood by now that I want to do my own game, but Luca's Art's master move was making a engine that could be applied to many games. That's how they could launch that tremendous amount of awesome titles in a short period of time, throwing new stories at us without having to teach us how to play each of those games individually (remember: internet wasn't THAT popular at the 90's). Whenever something new was launched, you instantly got the idea and was able to play the new game from start to finish. Today that engine is shared through scummvm, please take a look if you're into that kind of geek old stuff.

 

I cannot make a huge thing like this a game engine inside SAP, but I can create a framework for adventure games using ABAP. A main program and a set of classes responsible for launching the adventure game, and serving automated methods for handling rooms, screen objects, actions, messages and such. The game you saw on the video, "Zombie Attack", was made using an initial prototype of that framework - the one I lost when my installation crashed.

 

 

3. Community Help

 

It's good to create something by yourself, but I feel I can get a lot more from this project if I share the steps of making this framework here on SCN. It will be a blog like this one, sharing the UML diagrams, initial prototypes and the source code.

 

Now that the Code Exchange is shutting down, I'm not sure where I could post releases and the final version, but this is something that will hopefully be covered by the end of this project. In the mean time, I'll use blog posts to share the progression.

 

I'll definitely hear you, so please, do share your thoughts to improve my work. Like I said I'm far away from being an expert in OO, UML, etc, so any suggestions are welcome. Of course I won't change every little thing, but that's the joy of discussing development topics (check this and this - I can spend days into good discussions!).

 

 

4. Next Steps

 

I already started drawing the UML class diagram for this project. I'll also explain in details how things are going to work inside the framework (like rooms, actions, etc). I do not want to give any dates (we're all busy on the SAP world), but let's just say I'll do my best to release it by the end of next week. If you have any ideas for this project, please share through comments.

 

The "POC game" I want to implement using my framework is "Zombie Attack". Everybody loves a Zombie Game these days, right?   The version on that video is not using any items (like a shotgun, shells, tools, etc..), but I'm thinking about adding something to handle them. Let's see how far I can get.

 

One thing I would love to see is someone else making their own game using the final framework. Even if it's a two-room game, it would make me extremely happy (that's a personal goal for this project).

 

I'll also cross-post some of the information from this blogs on my personal ABAP blog.  We have a cool community in Brazil, but sadly most people still have the language barrier to use SCN, especially abap noobs (beginners). I'll do my best to forward them to where things are really happening.

 

 

Thanks for reading, and stay tuned for more gaming!

A Quick View on different SPs of SAP NW 7.31 regarding Quality & Disruptiveness

$
0
0

For me as software architect the last time has been really difficult – I was uncomfortable about the quality of AS ABAP software components. I spend too much time analyzing errors and in for some of them there working but not satisfying solutions. One source of the problems are disruptions which I mentioned on SCN and I told you that fortunately SAP could help in many cases.

 

In the meantime I learned that some of my calculations are in favor of SAP because I encountered a kind of “morass” in software components that was deleted and didn’t occur in my statistics because it consists of elements that are not assigned to a software component and therefore don’t appear in my statistics.

 

Then I had the feeling that some SPs of NW 7.31 had a terrible quality– especially SP4 and SP5 because in two strategic frameworks disruptive errors have been shipped and in another strategic frameworks the number of OSS messages much too high. I had mixed feelings when looking at different SPs of NW 7.31 and I am asking what happened here. Of course I can only guess but I don’t trust my impression so I tried to find out what was going on.

 

Nearly no Deletions from SP 5 to SP 8

My first question was whether SAP continued to delete the platform and I was surprised. At first some good news: from SP5 to SP8 there have been no deletions in SAP_ABA - congratulations!  The number of TADIR objects grew from 47.871 objects to 48.347 objects which is under 1% new development. The same is true for SAP_BASIS: I found only 385 deletions, but if you look at the deletions then you will find many classes like CL_EPM_PD_UPLOAD_FORM_FEEDER which belong to NetWeaver demo application. The software component grew from 251.069 to 254.040 which is roughly 1%.

 

What happened from SP5 to SP8?

It seems to me that from SP5 to 8 SAP fixed bugs but didn’t neither ship new functionality nor deleted anything. It seems to me that in these SPs only bugs have been fixed which is the purpose of an SP.

 

This is quite in line with my personal experience. My first test of NW 7.31 software started with SP3 and I didn’t found any problems. In SP4 and SP5 I encountered some severe problems. Thanks to SAP they have been solved in OSS notes and in SP6, 7 and 8. From my experience upgrading to SP8 was a good decision.

 

My Personal Conclusion

I experienced the following:

  • some SPs (especially 4 and 5) had a very poor quality
  • at the moment I can’t predict the costs of a SP upgrade in terms of test effort
  • upgrading to some SPs has been more problematic than implementation of some Ehps

At the moment I am a bit helpless. My former strategy of estimating disruptivity of Ehps early (and at a low SP level is failing) because everything can change with a new SP. As consequence at the moment some SPs require so much test effort that I’m thinking of additional investments in automated software tests.

 

The reasons is simple: I expect that new frameworks can be unstable but bug in strategic frameworks that are foundations of business solutions are fatal.

 

My Advice to SAP: Improve the Quality of SPs and keep an Eye especially on old Code

I hope that SAP will continue the strategy to prevent deletions.

 

I think customers will embrace new SAP NetWeaver features in SPs as long as the platform remains stable. But achieving high software quality and stability should be highest priority. And from experience there is much room for improvement - especially the quality of SP4 to 7 was poor from my experience.

 

For me it is especially annoying that some changes in old code had drastic and negative effects on stability. In my opinion SAP should change old code only if the following preconditions are met:

  • the change is compatible and so no disruption will occur and
  • the change has been thoroughly tested.

Dependency Injection for ABAP

$
0
0



Dependency Injection for ABAP:

Loose Coupling and Ease of Testing

Overview

What Is Dependency Injection?

Unit testing is often made more difficult by the heavy use of classes as namespaces and the proliferation of static methods to encapsulate configuration code.

Dependency injection is a design pattern that shifts the responsibility of resolving dependencies to a dedicated dependency injector that knows which dependent objects to inject into application code. Dependency injection offers a partial solution to our problem, by offering an elegant way to plug in either the new objects taking over the responsibilities of static methods, or others required for testing purposes.

[Niko Schwarz, Mircea Lungu, Oscar Nierstrasz, “Seuss: Decoupling responsibilities from static methods for fine-grained configurability”, Journal of Object Technology, Volume 11, no. 1 (April 2012), pp. 3:1-23, doi:10.5381/jot.2012.11.1.a3.]

Why Use Dependency Injection?

Some of the benefits of dependency injection in the ABAP context include:

  • Loose coupling of code
    • An application knows about an interface, and only deals with the interface. The dependency injection system is responsible for hooking the interface reference up to an actual instance of functionality.
  • Ease of testing
    • The dependency injection system can be triggered so that it only instantiates test implementations and mock functionality. This means a developer can test the real system with some functionality switched out, easing testing of parts of a system.

In a real world scenario, dependency injection could be used in parts of an application such as accessing configuration data or handling reading and writing of application data to the database. In a testing scenario, we need to test using a specific configuration for predictable results. We also may not want to save data on the database, and we may depend on specific data being used for tests. Using dependency injection, we can ensure a known and stable configuration is used during the test, and use specific mock data provided instead of data directly from the database, to make sure the data is processed as required.

Dependency Injection in Action

Using RTTI and some Object Oriented Data Dictionary metadata stored within SAP, a straightforward and easy to use approach can be taken to implement this functionality. In this section we have code snippets outlining the approach taken, including UML diagrams. The entire working example can also be downloaded for installation and experimentation.

An Example Report

We will start with an example of dependency injection in action using a basic report. For our simple program, we have an interface containing some business logic, in this case configuration data, called zdi_if_config. We have several implementations of the interface, each of which is intended for a different scenario. For everyday use, we want our application to instantiate the default class, zdi_if_config_def. Another department would like the functionality to behave a little differently, but we don’t want to go straight in and modify our default class, so we create zdi_if_config_cust which descends from the default class and replaces some of the functionality. Finally, when we’re testing our application we want to modify how the default class works, returning test data so we can be sure the environment is not affecting how the application runs – for example, providing a static configuration so we know exactly what behaviour to expect when testing. For this purpose, we have the zdi_if_config_test class.

 

[UMLRelationshipHierarchy.png]

 

The application itself is not responsible for instantiating instances of our interface – this is passed off to the dependency injection system, which makes a decision from the available implementations of an interface and instantiates an instance of a class accordingly.



Note: It is worth highlighting the fact that despite discussing the different implementing classes above, the program itself knows nothing of these implementations, and contains no references at all to these types. From the point of view of the program, the interface zdi_if_config is the only known type and the only type dealt with. This is one of the benefits of dependency injection – the program is now very loosely coupled to the implementation of the functionality. All the program needs to know is that there’s a contract for some behaviour it needs, how that contract is fulfilled doesn’t matter to the program.


 

For this example, we have a data variable which references our interface. The dependency injection system will automatically create an instance for the variable, the underlying functionality depending on the scenario (in this case, a declaratively defined mode.)

 
data:
    lif_config
typerefto zdi_if_config.


We start in standard mode – here we always use the default class unless an alternative implementation has been specified. We will inject an instance into the variable, and the expected outcome is a reference containing an instance of the alternative class.

 

  inject:
    lif_config.
" instantiates alternative class

 

In this case, lif_config will contain an instance of zdi_if_config_cust. Next, we will go into test mode, and repeat the same procedure. When asking for a reference to our interface, the system finds the test class and instantiates this. 

 

  clear lif_config.
  test_mode.
" indicates we want a class tagged with test tag
  inject:
    lif_config.
" instantiates test class

 

In this case, lif_config will contain an instance of zdi_if_config_test. Finally, we will go into pure mode. Here, we want to ignore any alternative implementations and use only default implementations. Pure mode is useful for when we have developed alternative implementations, but need to use the original default implementation for some reason.

 

  clear lif_config.
  pure_mode. " indicates we want a class tagged with default tag
  inject:
    lif_config.
" instantiates default class

 

In this case, lif_config will contain an instance of zdi_if_config_def.



Note: The different modes have been declaratively defined, but they could just as easily be configured, allowing dynamic alteration of how the application instantiates instances without code changes. The actual functionality to use could also be configured, for example specifying that a certain class should be instantiated when a specific user requests an instance for a specific interface.


Unit Testing

In normal operation, the injection would be performed only once per scope. The functionality may be needed in several places throughout the application, and the variable would be injected in all the places required. If a test scenario is needed, the DI test mode would be entered once at the beginning of the unit test (during set-up) and then the application objects would be instantiated. Every time the application requested an instance for the configuration, a test instance would be provided by the DI.

 

class bigapp_app_unit_test definitionfor testing.
 
privatesection.
   
class-data:
      mif_app
typerefto zbigapp_if_cntrl.
   
class-methods:
      class_setup.
   
methods:
      test_printing
for testing.
endclass.

class bigapp_app_unit_test implementation.
 
method class_setup.

   
data:
      lif_mod
typerefto zbigapp_if_model.


* safe in the knowledge that the app will use the test configuration
* and any other test injectables we have, such as database persistence
* overriding classes or a dummy user interface implementation.
    test_mode.

* instantiate the application model. The injection is performed

* inside of this call.

    lif_mod = zbigapp_cl_model_fact=>load(
     
exporting
        i_key =
'0042/DMO/000/00' ).

* instantiate the application controller.
    mif_app = zbigapp_cl_cntrl_fact=>create(
     
exporting
        i_model = lif_mod ).

 
endmethod.

 
method test_printing.

 

* make sure the test device is configured for the app.
* the real IMG configuration may have an alternative value
* for the current user, but the test configuration class
* overrides this so we use a specific device during testing.


    cl_aunit_assert=>assert_equals(
      act = mif_app->m_device
     
exp = 'TEST_DEVICE'
      msg =
'Test device was not configured for application').


* tell the application to print some data.
    mif_app->action( zbigapp_if_cntrl=>mcc_print ).


* check our test device to see whether the data was ok.
    cl_aunit_assert=>assert_equals(
      act = zbigapp_test_device=>m_printdata_ok( )
     
exp = 'X'
      msg =
'Test device reports print data was not ok').
 
endmethod.   
endclass

Implementation Approach

Here we will look at the implementation of the injection functionality. The inject command is simply a macro that passes the reference along to a static class method called zdi_cl_injection=>create_inst( ). The single changing parameter is called c_ref, of type any.

 

method create_inst.

 
data:
    li_ifcl_items   
type mt_classlist_tt,
    lvc_ifcl_item   
type mt_classitem,
    li_tags         
type mt_taglist_tt,
    lr_tag          
type mt_tagitem,
    lr_map          
type mt_classmap,
    lcl_descr_ref   
typerefto cl_abap_refdescr,
    lcl_abap_typdscr
typerefto cl_abap_typedescr.


First, we get some type information using the SAP RTTI system. We need to determine the type of the variable passed in, to make sure it’s a reference and get the dictionary name of the underlying interface or class.


* determine the dictionary type of the reference that was passed in.

  lcl_descr_ref ?= cl_abap_refdescr=>describe_by_data( c_ref ).
  lcl_abap_typdscr = lcl_descr_ref->get_referenced_type( ).

  lvc_ifcl_item = lcl_abap_typdscr->get_relative_name( ).

 
if lvc_ifcl_item isinitial.
   
raise nondictionary_type.
 
endif.


Next, we check our cache of previously requested instances. If a class has already been determined for this functionality, then we simply instantiate the class and return the instance.


* check our cache..
 
readtable mi_cache into lr_map
   
withkey source = lvc_ifcl_item.

 
if sy-subrc eq0.
   
create object c_ref type (lr_map-target).
   
return.
 
endif.

  lr_map-source = lvc_ifcl_item.


Next, we vary behaviour depending on whether the reference passed in is a reference to a class of interface. We are building up a list of potential instance candidates, so when a class is passed in we simply add it to the list (and we’ll look up descendants in a later step.) If an interface was passed in, we fetch a list of all classes that implement the interface (using table vseoimplem.)


* input can be a class or an interface whose imp'ing classes we want.
 
case lcl_abap_typdscr->type_kind.

   
when cl_abap_typedescr=>typekind_class.

     
append lvc_ifcl_item to li_ifcl_items.

   
when cl_abap_typedescr=>typekind_intf.

      get_imp_classes(
" classes that implement the passed in interface
       
exporting
          i_interface = lvc_ifcl_item
       
importing
          e_classes = li_ifcl_items
      ).

   
whenothers.
     
raise not_a_reference.
 
endcase.

Next, we explode the dependency tree of the classes we have collected (using table vseoextend.) This is required as the technique we use for selecting implementers of an interface only returns the classes directly implementing an interface, and not the descendants which do not explicitly define the implementation of the interface. Also, if a class reference was passed in then we need to fetch the potential candidates, which would consist of descendants of the class.

 

explode_descendents( " get entire descendant tree.
   
changing c_classlist = li_ifcl_items ).

 
if li_ifcl_items isinitial.
   
raise no_implementing_classes.
 
endif.


Next, we analyse the class list and determine any tags associated with them (using table seotypepls, which contains the forward declaration list which we have hijacked for tagging!) Possible tags include being flagged as a default class, an alternative class or a test class.
 

fetch_class_tags(
   
exporting
      i_classlist = li_ifcl_items
   
importing
      e_taglist = li_tags
  ).


Next, we apply our selection logic – if we are in test mode, we look for a test class; if we are in pure mode we look for a default class; otherwise we look for an alternative class, failing that a default class, and failing that the first class in the list.


 
do.
   
case mvb_mode.
     
when mcc_mode_test.
* if we're in test mode, read first test class if exists.
        get_target_with_tag mcc_tag_tst.
     
when mcc_mode_pure.
* if we're in pure mode, read first default class if exists.
        get_target_with_tag mcc_tag_def.
   
endcase.

* see if an alternative class exists.
    get_target_with_tag mcc_tag_alt.

* see if we have a class marked as standard.
    get_target_with_tag mcc_tag_def.

* fall through, when no keywords found just return first class.
   
readtable li_ifcl_items into lvc_ifcl_item
     
index1.
   
exit.
 
enddo.

 
if lvc_ifcl_item isinitial.
   
raise no_implementing_classes.
 
endif.


Next, we instantiate the class we want to use, and put the reference into c_ref.


 
try.
     
create object c_ref type (lvc_ifcl_item).
   
catch cx_sy_create_object_error.
     
raise instantiation_failed.
 
endtry.


Finally, we cache the name of the class and map it to the name of the type of the reference that was passed in.


  lr_map-target = lvc_ifcl_item.
 
append lr_map to mi_cache.

endmethod.

 

Downloads

Files containing the implementation can be found on the project page: https://bitbucket.org/zmob/di/downloads. This includes two SAPLink nuggets. Install NUGG_ZDI_IF.nugg first - you'll need the interface extension for SAPLink; then install NUGG_ZDI.nugg.

Next Steps (Future Articles)

  • Injecting constructor parameters on the fly
  • Configuration based selection of implementing functionality
  • Containers for managing lifecycle of objects

 

----

Test Report

report zdi_prog.

 

data:

  lvs_msg type string.

 

define inject.

*> &1 ref to interface or class

  zdi=>create_inst(

    changing c_ref = &1 ).

  assert &1 is not initial.

end-of-definition.

 

define test_mode.

  zdi=>test_mode( ).

end-of-definition.

 

define pure_mode.

  zdi=>pure_mode( ).

end-of-definition.

 

define prn.

*> &1 obj to test

  lvs_msg = &1->test( ).

  write lvs_msg.

  new-line.

end-of-definition.

 

start-of-selection.

 

* we have the business logic interface:

*   ZDI_IF

* we have business logic classes implementing ZDI_IF:

*   default (standard, from us) ZDI_DEFAULT

*   alternative (customer)      ZDI_ALTERNATIVE

*   test (for units)            ZDI_TEST

 

  data:

    lcl_di1 type ref to zdi_default,

    lif_di2 type ref to zdi_if,

    lcl_di3 type ref to zdi_default,

    lif_di4 type ref to zdi_if,

    lif_di5 type ref to zdi_if.

 

* the business logic class that is instantiated varies depending on the

* mode we are in. Within Unit tests, the test mode could be activated

* and any configuration and persistence classes could be switched out.

 

  inject:

    lcl_di1, " instantiates alternative class ZDI_ALTERNATIVE

    lif_di2. " instantiates alternative class ZDI_ALTERNATIVE

 

  test_mode. " indicates we want a class tagged with test tag

  inject:

    lcl_di3, " instantiates alternative class ZDI_ALTERNATIVE

    lif_di4. " instantiates test class ZDI_TEST

 

  pure_mode. " indicates we want a class tagged with default tag

  inject:

    lif_di5. " instantiates default class ZDI_DEFAULT

 

  prn:

    lcl_di1, " alternative - alternative is a descendant of default

    lif_di2, " alternative - alternative implements interface

    lcl_di3, " alternative - test class is not related to default

    lif_di4, " test - test implements interface

    lif_di5. " default - default implements interface and is tagged def

SM30, change standard width of Tablecontrol

$
0
0

One thing that always bothered me with the Table Maintenance Generator is that when we create a Dialog for a table with many fields the Table Control always show a width of 80 columns, even when the screen has space to show more content.

 

Wouldn't be great if we could harness this lost space?

 

Well, you can say, there is a simple fix for this. We can manually change the width of the Table Control, but the problem with this approach is that when the Generator is executed again (because a field was added to the table for example), the Table Control returns to the 80 columns layout.

 

With the solution proposed below, every time that the table is called in SM30, if the width is less than the desired the code kicks in and resizes the Table Control.

 

Solution:

 

Call the function to change it in the initialization event of the program using "Events" and pass to it the desired width of the Table Control. If the Table control and the enclosing canvas is less than the value passed the function change the width and re-generate the Dialog screen.

 

FUNCTION zsd_resize_table_ctrl.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_TABLE) TYPE  STRING
*"     REFERENCE(IV_MAINT_FG) TYPE  STRING
*"     REFERENCE(IV_DYNPRO_NO) TYPE  CHAR4
*"     REFERENCE(IV_WIDTH) TYPE  I
*"----------------------------------------------------------------------  CHECK iv_width <= 255.  DATA:    BEGIN OF gs_dynpro_descr,      prog   TYPE progname,      dynpro TYPE char4,    END OF gs_dynpro_descr.  DATA:    lv_fnam TYPE d021s-fnam,    h TYPE d020s,    ls_f TYPE d021s,    f TYPE d021s OCCURS 0 WITH HEADER LINE,    e TYPE d022s OCCURS 0 WITH HEADER LINE,    m TYPE d023s OCCURS 0 WITH HEADER LINE.  DATA:    m1 TYPE string,    l1 TYPE string,    w1 TYPE string.  CONCATENATE 'SAPL' iv_maint_fg INTO gs_dynpro_descr-prog.  gs_dynpro_descr-dynpro = iv_dynpro_no.  CONCATENATE 'TCTRL_' iv_table INTO lv_fnam.  IMPORT DYNPRO h f e m ID gs_dynpro_descr.  READ TABLE f INTO ls_f WITH KEY fnam = lv_fnam.  CHECK sy-subrc = 0.  CHECK h-noco < iv_width.  h-noco = iv_width.

* convert to hexa
  DATA: lv_crmt_ei_kb_id TYPE crmt_ei_kb_id.  lv_crmt_ei_kb_id = iv_width - 2.  CALL FUNCTION 'CRM_EI_KB_CONV_DEC_TO_HEX'    EXPORTING      iv_decimal = lv_crmt_ei_kb_id    IMPORTING      ev_hex     = lv_crmt_ei_kb_id.  CHECK NOT lv_crmt_ei_kb_id+30(2) IS INITIAL.  ls_f-leng = lv_crmt_ei_kb_id+30(2). " '9B'. " 155 em hexa  MODIFY f FROM ls_f INDEX sy-tabix TRANSPORTING leng.  CHECK sy-subrc = 0.  EXPORT DYNPRO h f e m ID gs_dynpro_descr.  GENERATE DYNPRO h f e m ID gs_dynpro_descr MESSAGE m1 LINE l1 WORD w1.

ENDFUNCTION.

 

In the Table Maintenance Generator select the menu below:

 

events.jpg

 

Add the event 19, "after initializing global variables, field symbols, etc." for events reference see http://help.sap.com/saphelp_nw70/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/content.htm

 

form.jpg

 

Call the function passing, the maintenance table, maintenance function group, dynpro number and desired width.

 

FORM check_and_resize_tablecontrol.  CALL FUNCTION 'ZSD_RESIZE_TABLE_CTRL'    EXPORTING      iv_table           = 'ZTABLE'      iv_maint_fg        = 'ZMAINT_FG'      iv_dynpro_no       = '1100'      iv_width           = 160.

ENDFORM.

 

And that's about it, see ya!

Mini SIZZLING Hot game in abap

$
0
0

My first post !

 

First press: 'Cred' button for adding 'credits', then chose the 'Bet' botton for betting value, then 'Spin'.

When you 'win' you can double the winning amount by pressing '<5' or  '>=5'.

 

Have fun!

 

sly.JPG

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

REPORT  zMini_SIZZLING.
TABLES SSCRFIELDS.
TYPE-POOLS: icon.
DATA: w_num TYPE i.
data: credit(4) TYPE p DECIMALS 0,
       cred2 TYPE i,
       bet TYPE p DECIMALS 0.
data: a type i,
        CASTIG TYPE P DECIMALS 0,
        castig2 TYPE p DECIMALS 0,
       B TYPE I.

DATA: FLAG, count(10) type c ,
f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,
p1(2) type c,
p2(2) type c,
player(2) type c,
ch type c,
rand(2) TYPE c.


SELECTION-SCREEN BEGIN OF BLOCK b1                          "rad1
WITH FRAME TITLE text-002 ."no intervals.
PARAMETERS: Message1(10) TYPE c MODIF ID ABC,
             message(10) type c MODIF ID ABC,
             BETS(2) TYPE C MODIF ID ABC,
             wining(10) MODIF ID ABC.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN:
BEGIN OF LINE,
   PUSHBUTTON 2(10) BUTgame1 USER-COMMAND CLIgame1 MODIF ID sc1,
   PUSHBUTTON 14(10) BUTnet1 USER-COMMAND net MODIF ID sc1,
END OF LINE,
BEGIN OF LINE,
PUSHBUTTON 2(10) BUT1 USER-COMMAND CLI1 MODIF ID sc1,
PUSHBUTTON 12(10) but22 USER-COMMAND CLI2 MODIF ID sc2,
PUSHBUTTON 22(10) BUT3 USER-COMMAND CLI3 MODIF ID sc3,
PUSHBUTTON 32(10) BUT101 USER-COMMAND CLI3 MODIF ID sc3,
PUSHBUTTON 42(10) BUT102 USER-COMMAND CLI3 MODIF ID sc3,
PUSHBUTTON 67(10) BUTdub USER-COMMAND CLI000 MODIF ID sc3,
END OF LINE,
BEGIN OF LINE,
PUSHBUTTON 2(10) BUT4 USER-COMMAND CLI4 MODIF ID sc4,
PUSHBUTTON 12(10) BUT5 USER-COMMAND CLI5 MODIF ID sc5,
PUSHBUTTON 22(10) BUT6 USER-COMMAND CLI6 MODIF ID sc6,
PUSHBUTTON 32(10) BUT121 USER-COMMAND CLI3 MODIF ID sc3,
PUSHBUTTON 42(10) BUT122 USER-COMMAND CLI3 MODIF ID sc3,
END OF LINE,
BEGIN OF LINE,
PUSHBUTTON 2(10) BUT7 USER-COMMAND CLI7 MODIF ID sc7,
PUSHBUTTON 12(10) BUT8 USER-COMMAND CLI8 MODIF ID sc8,
PUSHBUTTON 22(10) BUT9 USER-COMMAND CLI9 MODIF ID sc9,
PUSHBUTTON 32(10) BUT131 USER-COMMAND CLI3 MODIF ID sc3,
PUSHBUTTON 42(10) BUT132 USER-COMMAND CLI3 MODIF ID sc3,


END OF LINE,
BEGIN of line,

END OF line,
BEGIN OF LINE,
   PUSHBUTTON 2(37) BUT10 USER-COMMAND CLI10 MODIF ID sc3,
   PUSHBUTTON 41(5) BUT11 USER-COMMAND CLI11 MODIF ID sc9,
   PUSHBUTTON 47(5) BUT12 USER-COMMAND CLI12 MODIF ID sc9,
   PUSHBUTTON 65(5) BUTmin USER-COMMAND CLI001 MODIF ID sc3,
   PUSHBUTTON 74(5) BUTmax USER-COMMAND CLI002 MODIF ID sc9,
end of line,

BEGIN of line,

END OF line.
SELECTION-SCREEN END OF BLOCK b1.                           "rad1.

form box_disable using ch.
   LOOP AT SCREEN.
     IF screen-group1 = ch.
       screen-input = '0'.
       MODIFY SCREEN.
     ENDIF.
   ENDLOOP.
endform. "box_disable

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.

   if f1 = 1.
     perform box_disable using 'SC1'.
   endif.
   if f2 = 1.
     perform box_disable using 'SC2'.
   endif.
   if f3 = 1.
     perform box_disable using 'SC3'.
   endif.
   if f4 = 1.
     perform box_disable using 'SC4'.
   endif.
   if f5 = 1.
     perform box_disable using 'SC5'.
   endif.
   if f6 = 1.
     perform box_disable using 'SC6'.
   endif.
   if f7 = 1.
     perform box_disable using 'SC7'.
   endif.
   if f8 = 1.
     perform box_disable using 'SC8'.
   endif.
   if f9 = 1.
     perform box_disable using 'SC9'.
   endif.

AT SELECTION-SCREEN .


   CASE SSCRFIELDS.
     when 'CLIGAME1'.
       "SUBMIT Z_TEST_XO_1  VIA SELECTION-SCREEN AND RETURN.
CALL TRANSACTION 'ZF_GAME_2' .
       when 'NET'.
       SUBMIT ZF_HTML1  VIA SELECTION-SCREEN AND RETURN.

     when 'CLI000'.
       DATA: BROWSER_TYPE       LIKE TOLE-APP VALUE 'INTERNETEXPLORER.APPLICATION',

       LV_HELP_MODE        TYPE CHAR1,

       LV_WINDOW_NAME      TYPE SYDATAR.



CALL FUNCTION 'GET_WEBGUI_HELP_MODE'

      IMPORTING

           HELP_MODE = LV_HELP_MODE.

IF LV_HELP_MODE = 'X'.

   LV_WINDOW_NAME = 'SAPNet'.

ELSE.

   LV_WINDOW_NAME = SPACE.

ENDIF.


     CALL FUNCTION 'CALL_BROWSER'

      EXPORTING

           URL                    = 'http://www.youtube.com/watch?v=6dja9wIHPJo&feature=player_embedded#t=59s'

           BROWSER_TYPE           = BROWSER_TYPE

           WINDOW_NAME            = LV_WINDOW_NAME

      EXCEPTIONS

           FRONTEND_NOT_SUPPORTED = 1

           FRONTEND_ERROR         = 2

           PROG_NOT_FOUND         = 3

           NO_BATCH               = 4

           UNSPECIFIED_ERROR      = 5

           OTHERS                 = 6.

IF SY-SUBRC NE 0.

   WRITE:/ 'Browser not called.'.

ENDIF.



     WHEN 'CLI001'.
       castig2 = wining.
       IF A = 1.
         CALL FUNCTION 'ISB_RANDOM_CHAR' "
         EXPORTING
          length = 1                  " sy-tabix
           pattern ='1234567890'                   "
         IMPORTING
           ran_char = butDUB                 "
         EXCEPTIONS
           INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR
         IF BUTDUB < 5 .
           WINING = WINING * 2.
         ELSE.
           MESSAGE1 = 'You Lost'.
           WINING = 0.
           A = 0.
         ENDIF.
       ENDIF.
     WHEN 'CLI002'.
       IF A = 1.
         CALL FUNCTION 'ISB_RANDOM_CHAR' "
         EXPORTING
          length = 1                  " sy-tabix
           pattern ='1234567890'                   "
         IMPORTING
           ran_char = butDUB                 "
         EXCEPTIONS
           INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR
         IF BUTDUB >= 5 .
           WINING = WINING * 2.
         ELSE.
           WINING = 0.
           MESSAGE1 = 'You Lost'.
           A = 0.
         ENDIF.
       ENDIF.
     when 'CLI11'.
       credit = credit + 500.
       MESSAGE = credit.
      " PERFORM beting.
     when 'CLI12'.
       "PERFORM beting.
       IF BET < 50.
         BET = BET + 10.
       ELSE.
         BET = 10.
       ENDIF.
       BETS = BET.
     when 'CLI10'.
       IF credit < bet.
           bet = credit.
           bets = bet.
       ENDIF.
        butdub = 'Press?!'.
       count = 1.
       credit = credit - bet.
       IF wining <> 0 .
             wining = wining + bet.
       ENDIF.
       MESSAGE1 = ''.
       CREDIT = CREDIT + WINING.
       IF credit <= -10.
         PERFORM reset.
       else.
         MESSAGE = credit.

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but101                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but102                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but121                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR
         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but122                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but131                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but132                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but1                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but22                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but3                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but4                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but5                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but6                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but7                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but8                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         CALL FUNCTION 'ISB_RANDOM_CHAR' "
           EXPORTING
            length = 1                  " sy-tabix
             pattern ='1234712341234'                   "
           IMPORTING
             ran_char = but9                 "
           EXCEPTIONS
             INVALID_INPUT = 1           . "  ISB_RANDOM_CHAR

         " prima linie ****************
         IF but101 = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but101
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but101 = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but101
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but101 = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but101
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but101 = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but101
             EXCEPTIONS
               OTHERS = 0.
         elseif  but101 = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but101
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.


         IF but1  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but1
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but1  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but1
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but1  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but1
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but1  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but1
             EXCEPTIONS
               OTHERS = 0.
         elseif  but1  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but1
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but3  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but3
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but3  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but3
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but3  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but3
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but3  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but3
             EXCEPTIONS
               OTHERS = 0.
         elseif  but3  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but3
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but102  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but102
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but102  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but102
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but102  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but102
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but102  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but102
             EXCEPTIONS
               OTHERS = 0.
         elseif  but102  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but102
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but22  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but22
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but22  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but22
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but22  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but22
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but22  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but22
             EXCEPTIONS
               OTHERS = 0.
         elseif  but22  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but22
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.
         "a doua linie ********************
         IF but121 = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but121
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but121 = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but121
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but121 = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but121
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but121 = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but121
             EXCEPTIONS
               OTHERS = 0.
         elseif  but121 = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but121
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.


         IF but4  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but4
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but4  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but4
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but4  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but4
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but4  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but4
             EXCEPTIONS
               OTHERS = 0.
         elseif  but4  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but4
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but6  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but6
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but6  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but6
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but6  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but6
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but6  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but6
             EXCEPTIONS
               OTHERS = 0.
         elseif  but6  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but6
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but122  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but122
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but122  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but122
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but122  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but122
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but122  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but122
             EXCEPTIONS
               OTHERS = 0.
         elseif  but122  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but122
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but5  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but5
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but5  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but5
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but5  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but5
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but5  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but5
             EXCEPTIONS
               OTHERS = 0.
         elseif  but5  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but5
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         "a doua linie ********************
         IF but131 = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but131
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but131 = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but131
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but131 = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but131
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but131 = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but131
             EXCEPTIONS
               OTHERS = 0.
         elseif  but131 = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but131
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.


         IF but7  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but7
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but7  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but7
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but7  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but7
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but7  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but7
             EXCEPTIONS
               OTHERS = 0.
         elseif  but7  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but7
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but9  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but9
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but9  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but9
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but9  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but9
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but9  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but9
             EXCEPTIONS
               OTHERS = 0.
         elseif  but9  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but9
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but132  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but132
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but132  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but132
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but132  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but132
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but132  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but132
             EXCEPTIONS
               OTHERS = 0.
         elseif  but132  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but132
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         IF but8  = 1.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = icon_okay
               text   = '1'
               info   = '1'
             IMPORTING
               RESULT = but8
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but8  = 2.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_LOCKED
               text   = '2'
               info   = '2'
             IMPORTING
               RESULT = but8
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but8  = 3.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_GREEN_LIGHT
               text   = '3'
               info   = '3'
             IMPORTING
               RESULT = but8
             EXCEPTIONS
               OTHERS = 0.
         ELSEIF but8  = 4.
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_YELLOW_LIGHT
               text   = '4'
               info   = '4'
             IMPORTING
               RESULT = but8
             EXCEPTIONS
               OTHERS = 0.
         elseif  but8  = 7 .
           CALL FUNCTION 'ICON_CREATE'
             EXPORTING
               name   = ICON_RED_LIGHT
               text   = '7'
               info   = '7'
             IMPORTING
               RESULT = but8
             EXCEPTIONS
               OTHERS = 0.
         ENDIF.

         PERFORM wining.
       ENDIF.

   ENDCASE.

*&---------------------------------------------------------------------*
*&      Form  reset
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form reset.
   wait up to 2 SECONDS.
   butgame1 = 'Jocul 2'.
   butnet1 = 'Net'.
   credit = 100.
   BUT1 = 'L'.
   but22 = 'E'.
   BUT3 = 'T'.
   BUT101 = ','.
   BUT102 = 'S'.
   BUT4 = 'P'.
   BUT5 = 'L'.
   BUT6 = 'A'.
   BUT121 = 'Y'.
   BUT122 = ' '.
   BUT7 = ' '.
   BUT8 = ' '.
   BUT9 = ' '.
   BUT131 = ' '.
   BUT132 = ' '.
   CALL FUNCTION 'ICON_CREATE'
     EXPORTING
       name   = icon_okay
       text   = 'Spin/Colect'
       info   = 'Click to Continue'
     IMPORTING
       RESULT = but10
     EXCEPTIONS
       OTHERS = 0.
   but11 = 'Cred'.

   but12 = 'Bet'.
   f1 = ' '.
   f2 =' '.
   f3 = ' '.
   f4 =' '.
   f5 = ' '.
   f6 =' '.
   f7 = ' '.
   f8 =' '.
   f9 = ' '.
   Message = 'New Game'.
** Score = ' '.
   count = 0.

endform. "reset

initialization.
   count = 0.
   butgame1 = 'Jocul 2'.
   butnet1 = 'Net'.
   BUT1 = p1.
   but22 = p1.
   BUT3 = p1.
   BUT4 = p1.
   BUT5 = p1.
   BUT6 = p1.
   BUT7 = p1.
   BUT8 = p1.
   BUT9 = p1.
   BUT101 = p1.
   BUT102 = p1.
   BUT121 = p1.
   BUT122 = p1.
   BUT131 = p1.
   BUT132 = p1.
   but11 = 'Cred'.
   but12 = 'Bet'.


   CALL FUNCTION 'ICON_CREATE'
     EXPORTING
       name   = icon_okay
       text   = 'Spin/Colect'
       info   = 'Click to Continue'
     IMPORTING
       RESULT = but10
     EXCEPTIONS
       OTHERS = 0.

   cALL FUNCTION 'MOVE_CHAR_TO_NUM'
     EXPORTING
       CHR             = but11
     IMPORTING
       NUM             = credit
     EXCEPTIONS
       CONVT_NO_NUMBER = 1
       CONVT_OVERFLOW  = 2
       OTHERS          = 3.
   IF SY-SUBRC <> 0.
   ENDIF.
   cALL FUNCTION 'MOVE_CHAR_TO_NUM'
     EXPORTING
       CHR             = but12
     IMPORTING
       NUM             = bet
     EXCEPTIONS
       CONVT_NO_NUMBER = 1
       CONVT_OVERFLOW  = 2
       OTHERS          = 3.

   IF SY-SUBRC <> 0.
   ENDIF.

*&---------------------------------------------------------------------*
*&      Form  wining
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form wining.

   a = 0.
   CASTIG = 0.
   B = 0.
   if but1 = but22 and but1 = but3 .
     IF but1 = but101.
       IF BUT1 = BUT102.
         IF BUT1 = '@0A\Q7@ 7' .
           CASTIG = 5 * ( CASTIG + 5 * BET ).
           B = 1.
         ELSE.
           CASTIG = 5 * ( CASTIG + 2 * BET ).
           B = 1.
         ENDIF.
       ENDIF.
       IF B = 0 AND BUT1 = '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 5 * BET ).
         B = 1.
       ELSEIF B = 0 AND BUT1 <> '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 2 * BET ).
         B = 1.
       ENDIF.
     ENDIF.
     IF B = 0 AND BUT1 = '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 5 * BET ).
       B = 1.
     ELSEIF B = 0 AND BUT1 <> '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 2 * BET ).
       B = 1.
     ENDIF.
     A = 1.
   ENDIF"PRIMA LINIE

   B = 0.
   if but4 = but5 and but4 = but6.
     IF but4 = but121.
       IF BUT4 = BUT122.
         IF BUT4 = '@0A\Q7@ 7' .
           CASTIG = 5 * ( CASTIG + 5 * BET ).
           B = 1.
         ELSE.
           CASTIG = 5 * ( CASTIG + 2 * BET ).
           B = 1.
         ENDIF.
       ENDIF.
       IF B = 0 AND BUT4 = '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 5 * BET ).
         B = 1.
       ELSEIF B = 0 AND BUT4 <> '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 2 * BET ).
         B = 1.
       ENDIF.
     ENDIF.
     IF B = 0 AND BUT4 = '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 5 * BET ).
       B = 1.
     ELSEIF B = 0 AND BUT4 <> '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 2 * BET ).
       B = 1.
     ENDIF.
     A = 1.
   ENDIF. "LINIE MIJLOC

   B = 0.
   if but7 = but8 and but7 = but9.
     IF but7 = but131.
       IF BUT7 = BUT132.
         IF BUT7 = '@0A\Q7@ 7' .
           CASTIG = 5 * ( CASTIG + 5 * BET ).
           B = 1.
         ELSE.
           CASTIG = 5 * ( CASTIG + 2 * BET ).
           B = 1.
         ENDIF.
       ENDIF.
       IF B = 0 AND BUT7 = '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 5 * BET ).
         B = 1.
       ELSEIF B = 0 AND BUT7 <> '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 2 * BET ).
         B = 1.
       ENDIF.
     ENDIF.
     IF B = 0 AND BUT7 = '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 5 * BET ).
       B = 1.
     ELSEIF B = 0 AND BUT7 <> '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 2 * BET ).
       B = 1.
     ENDIF.
     A = 1.
   ENDIF.                                                    "LINIE 3

   B = 0.
   if but7 = but5 and but7 = but3.
     IF but7 = but121.
       IF BUT7 = BUT132.
         IF BUT7 = '@0A\Q7@ 7' .
           CASTIG = 5 * ( CASTIG + 5 * BET ).
           B = 1.
         ELSE.
           CASTIG = 5 * ( CASTIG + 2 * BET ).
           B = 1.
         ENDIF.
       ENDIF.
       IF B = 0 AND BUT7 = '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 5 * BET ).
         B = 1.
       ELSEIF B = 0 AND BUT7 <> '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 2 * BET ).
         B = 1.
       ENDIF.
     ENDIF.
     IF B = 0 AND BUT7 = '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 5 * BET ).
       B = 1.
     ELSEIF B = 0 AND BUT7 <> '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 2 * BET ).
       B = 1.
     ENDIF.
     A = 1.
   ENDIF.                                                    "DIAG 2

   B = 0.
   if but1 = but5 and but1 = but9.                           "DIAG 1
     IF but1 = but121.
       IF BUT1 = BUT102.
         IF BUT1 = '@0A\Q7@ 7' .
           CASTIG = 5 * ( CASTIG + 5 * BET ).
           B = 1.
         ELSE.
           CASTIG = 5 * ( CASTIG + 2 * BET ).
           B = 1.
         ENDIF.
       ENDIF.
       IF B = 0 AND BUT1 = '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 5 * BET ).
         B = 1.
       ELSEIF B = 0 AND BUT1 <> '@0A\Q7@ 7' .
         CASTIG = 3 * ( CASTIG + 2 * BET ).
         B = 1.
       ENDIF.
     ENDIF.
     IF B = 0 AND BUT1 = '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 5 * BET ).
       B = 1.
     ELSEIF B = 0 AND BUT1 <> '@0A\Q7@ 7' .
       CASTIG = ( CASTIG + 2 * BET ).
       B = 1.
     ENDIF.
     A = 1.
   ENDIF.                                                    "LINIE 3

   IF a = 1.
     MESSAGE1 = 'You win '.
      butdub = 'Double?!'.
   else.
     MESSAGE1 = ''.
   ENDIF.
   WINING = CASTIG.
   BUTMIN = '<5'.
   BUTMAX = '>=5'.

endform. "check_x_win
*&---------------------------------------------------------------------*
*&      Form  BETING
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM BETING .


DATA: it_vbscript LIKE STANDARD TABLE OF soli WITH HEADER LINE,
       v_vbsfile LIKE rlgrap-filename.

*-----------------------------------------------------------------------
*  This code creates the vbScript to play sound ringin.wav
*-----------------------------------------------------------------------
APPEND: 'strSoundFile = "C:\WINDOWS\Media\notify.wav"' TO it_vbscript,
         'Set objShell = CreateObject("Wscript.Shell")' TO it_vbscript,
         'strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)' TO it_vbscript,
         'objShell.Run strCommand, 0, True' TO it_vbscript.

*-----------------------------------------------------------------------
*  Generated Script file must be downloaded into the TEMP folder of
*  the Windows environment
*-----------------------------------------------------------------------
CALL FUNCTION 'WS_QUERY'
   EXPORTING
     environment    = 'TEMP'
     query          = 'EN'
   IMPORTING
     return         = v_vbsfile
   EXCEPTIONS
     inv_query      = 1
     no_batch       = 2
     frontend_error = 3
     OTHERS         = 4.

IF sy-subrc <> 0.

   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

   CONCATENATE v_vbsfile '\my_script.vbs' INTO v_vbsfile.

*-----------------------------------------------------------------------
*   Script file is downloaded
*-----------------------------------------------------------------------
   CALL FUNCTION 'WS_DOWNLOAD'
     EXPORTING
       filename            = v_vbsfile
       filetype            = 'DAT'
       mode                = 'S'
     TABLES
       data_tab            = it_vbscript
     EXCEPTIONS
       file_open_error     = 1
       file_write_error    = 2
       invalid_filesize    = 3
       invalid_table_width = 4
       invalid_type        = 5
       no_batch            = 6
       unknown_error       = 7
       OTHERS              = 8.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ELSE.

*-----------------------------------------------------------------------
*  The Script file is executed
*-----------------------------------------------------------------------
     CALL FUNCTION 'WS_EXECUTE'
       EXPORTING
         commandline    = v_vbsfile
         program        = 'WSCRIPT.EXE'
       EXCEPTIONS
         frontend_error = 1
         no_batch       = 2
         prog_not_found = 3
         illegal_option = 4
         OTHERS         = 5.

     IF sy-subrc <> 0.

       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

     ENDIF.

   ENDIF.

ENDIF.

ENDFORM.                    " BETING

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

Getting started: ABAP-HR/HCM using PNP Logical databases

$
0
0

Logical databases is a differentiating factor in ABAP-HR since it is used extensively here. These logical databases are special ABAP programs that provide fundamental functionality required for reading and processing data related to HR.


SAP HR is divided into different sub-modules and most widely used of these sub-modules are Personnel Administration and Organizational Management. We have PNP and PNPCE logical database for Personnel Administration and PCH logical database for Organizational Management.


I will be covering the programming basics for using PNP (Personnel Administration) logical databases.


PNP for Personnel Administration– This logical database provides standard selection screen based on HR report category that is selected while creation. The data is selected based on the selection made on the selection screen. It also checks if the user who has started the report has the necessary rights/authorization required to read/process the data.


By default there are some report categories while having a pre-defined set of selection screen elements. But we can create our new HR report category to define custom selection screen elements. We can also add our custom selection screen elements in addition to the standard selection screen elements which exist in a pre-defined HR report category.


Sample structure of basic ABAP-HR report program


REPORT zreport.

 

INFOTYPES: 0001.       “This is the info type declaration area

 

TABLES: pernr.         “Key fields for Personnel Admin infotypes

 

 

START-OF-SELECTION.

GET PERNR.             “Get PERNR gets all data related to a PERNR

 

PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.

 

WRITE:/ P0001-PERNR,

        P0001-STELL,

        P0001-BEGDA.

 

ENDPROVIDE.

 

 

Infotypes are basically used to group related together. They provide information and store data for specific time periods. In the above sample program the INFOTYPE statement declares an internal table which is populated at the GET PERNR event.

For example if we have

INFOTYPE: 0001.

This instruction creates an internal table with structure p0001 and which is filled at the GET PERNR event. We also add MODE N to this instruction.

INFOTYPE: 0001 MODE N.

The addition of MODE N restricts data from filling into the internal table at GET PERNR.

 

GET PERNR statement is basically an event which triggers the data read operation into respective infotypes which have declared by using the INFOTYPES statement for each PERNR (Personnel Number) that satisfies the selection criteria.


Program Flow for GET PERNR event.

1.jpg

 

 

The flow of this program is completely dependent on the GET PERNR statement. It acts as a loop and processes all data related to each PERNR one by one. In the above example following sequence of steps occur:

  1. All data belonging to PERNR = 00009001 (example) is read into the internal table p0001 for the date range specified in the selection screen.
  2. All the statements below are executed and data related to above PERNR only exists in the internal tables which were defined at the infotype statement.
  3. After all the statements have been executed the program control goes back to GET PERNR statement, refreshes all the internal tables (like p0001) and reads new data related to the next PERNR = 00009002 into the respective internal tables.
  4. This process continues till all the valid PERNR are processed.

 

While each PERNR is processed we may need to process individual infotype depending on some constraints. A PROVIDE-ENDPROVIDE loop is used to evaluate individual infotypes.

For example:


PROVIDE * FROM p0001

                   BETWEEN pn-begda AND pn-endda.


* ABAP statements to process data for infotype 0001


ENDPROVIDE.

ABAP Report -> Mobile Application with zMob!

$
0
0

ss2.png

 

zMob is a powerful platform allowing the generation of mobile applications from simple ABAP reports. Behind the scenes, the report is converted into a mobile UI and passed to the end user's mobile device. Once data is collected, the user submits the data back to the SAP system, where your report processes the result in real-time. Your report writes lines that are relayed back to the mobile device, processed for special tags and rendered for the user.

 

The zMob library for SAP is open source (dual licensed under the LGPL and a commercial license,) and can be downloaded from the project page at https://bitbucket.org/zmob/sap.

 

A project using zMob to generate a mobile application from ABAP reports is Microbe, an open source (MIT) microblogging platform. A recent article outlines the functionality and configuration of Microbe, but here we shall look at the implementation in more detail, plus other features of zMob - this is the ABAP Development section after all!

ss_post_plus_code.png

As can be seen in the screen shot, the parameters of a report are mapped to the fields of a mobile application. The types of the parameters must be taken from the constants of the ZMOB class, and indicate the component or device data that the report would like to process. Following are the available types:

 

UI Components

 

ZMOB=>UI_MAP

Presents a map widget showing the current location of the device.

 

ZMOB=>UI_CAPTURE_BARCODE

Presents a button that can be clicked to capture the value of a barcode using the camera.

 

ZMOB=>UI_CAPTURE_AUDIO

Presents a button that can be clicked to capture audio from the device.

 

ZMOB=>UI_CAPTURE_PHOTO

Presents a button that can be clicked to capture a photo using the camera.

 

ZMOB=>UI_CAPTURE_VIDEO

Presents a button that can be clicked to capture a video using the camera.

 

ZMOB=>UI_CHECKBOX

Presents a simple checkbox component.

 

ZMOB=>UI_COMPASS

Presents a compass, which can be frozen on a heading by clicking.

 

ZMOB=>UI_DATE

Presents a date picker widget.

 

ZMOB=>UI_KEYWEEK

Presents a key-week picker widget.

 

ZMOB=>UI_DESCRIPTION

Presents a box for text entry that grows as more text is added.

 

ZMOB=>UI_DROPDOWN

Presents a drop down list of items.

 

ZMOB=>UI_EMAIL

Presents an input field specialized for email input.

 

ZMOB=>UI_NUMBER

Presents an input field specialized for number input.

 

ZMOB=>UI_PASSWORD

Presents an input field specialized for password input.

 

ZMOB=>UI_RADIO

Presents one item from a group of radio buttons.

 

ZMOB=>UI_SLIDER

Presents a widget used to select an integer value between a maximum and minimum value.

 

ZMOB=>UI_TELEPHONE

Presents an input field specialized for telephone number input.

 

ZMOB=>UI_TEXT

Presents an input field for plain text.

 

ZMOB=>UI_TEXT_HELP

Presents an input field for plain text with help attached.

 

ZMOB=>UI_TOGGLE

Presents a toggle button for On Off values.

 

ZMOB=>UI_URL

Presents an input field specialized for http address input.

 

Device Properties

 

ZMOB=>BG_ACCELEROMETER

Returns the value of the device accelerometer at time of submit.

 

ZMOB=>BG_GEOLOC_LATITUDE

Returns the value of the device latitude at time of submit.

 

ZMOB=>BG_GEOLOC_LONGITUDE

Returns the value of the device longitude at time of submit.

 

ZMOB=>BG_GEOLOC_ACCURACY

Returns the accuracy of the device longitude/latitude coordinates at time of submit.

 

ZMOB=>BG_GEOLOC_ALTITUDE

Returns the value of the device altitude at time of submit.

 

ZMOB=>BG_GEOLOC_ALTITUDEACCURACY

Returns the accuracy of the device altitude sensor at time of submit.

 

ZMOB=>BG_GEOLOC_HEADING

Returns the value of the device heading at time of submit.

 

ZMOB=>BG_GEOLOC_SPEED

Returns the value of the device speed at time of submit.

 

ZMOB=>BG_GEOLOC_TIMESTAMP

Returns the timestamp at which the geolocation data was last updated.

 

ZMOB=>BG_DEVICE_MODEL

Returns the device's model or the name of the product.

 

ZMOB=>BG_DEVICE_UUID

Returns an ID unique to the device.

 

ZMOB=>BG_DEVICE_VERSION

Returns version information for the operating system installed on the device.

 

ZMOB=>BG_PLATFORM

Returns information on the operating system installed on the device.

 

ZMOB=>BG_USER

Returns the configured user name for the SAP user using the device.

 

Start Of Selection

Once the user has entered data into the application, they click the "Submit to SAP" button and their form data is serialized. The data is then passed back to SAP and submitted to the corresponding report. The output from the report is sent back to the mobile application and rendered.

 

Tags within the returned data are interpreted and have special meanings.

 

  • <link:...> will cause a line in the results to become a link to another ABAP report or HTTP address.
  • <img:...> [planned] to allow specifying an inline image URL
  • <html> [planned] to allow HTML output embedded within the application
  • Other tags are planned for future implementation!

 

Example Source Code

 

Following is the code contained in zmicrobe_post and zmicrobe_index for the sample microblogging application Microbe. The code is simple and straightforward, and yet achieves impressive results thanks to zMob.

 

Note that because zmicrobe_index has no parameters defined, zMob skips an input screen and renders the results of calling start-of-selection directly for the user. The lines written to output are then shown to the user in a list view, including a link to the zmicrobe_post report.

 

* entry point into microbe mobile app

REPORT  zmicrobe_index.

DATA:
  msg TYPE zmicrobe_msgs,
  txt TYPE string.

START-OF-SELECTION.

WRITE 'Welcome to the Microbe demo microblogging platform.'.
NEW-LINE.

WRITE 'See original implementation in reports ZMICROBE_INDEX and ZMICROBE_POST.'.
NEW-LINE.

WRITE 'Post a message <link:ZMICROBE_POST>'.
NEW-LINE.

SELECT * FROM zmicrobe_msgs INTO msg
  UP TO 20 ROWS
  ORDER BY timestamp DESCENDING.

CONCATENATE msg-username 'posted' msg-message
  INTO txt SEPARATED BY space.

* todo: include thumbnails <img:> - extend db..
  WRITE txt.
  NEW-LINE.
ENDSELECT.

IF sy-subrc NE 0.
*    WRITE: 'Be the first to post a message!'.
ENDIF

mob_ss_index.png

REPORT  zmicrobe_post.

PARAMETERS:
  p_msg LIKE zmob=>ui_description,
  p_usr LIKE zmob=>bg_user.

START-OF-SELECTION.

DATA:
  msg TYPE zmicrobe_msgs.

msg-timestamp = 0.
msg-username = p_usr.
msg-message = p_msg.

INSERT zmicrobe_msgs FROM msg.
COMMIT WORK AND WAIT.

write:
  'Your message has been posted.', /,
  'Back to Microbe <link:ZMICROBE_INDEX>'.

mob_post.png

Debugging

 

The zMob emulation system can be used to test your installation and your own reports from within the browser. (It is also available in the Google Chrome store for free.)

 

After activating a report and configuring user access for SAP users, the URL to your SAP system can be entered into the browser based emulator, and you will be able to see and interact with your mobile application, including logging the communication between SAP and the mobile application.

ss_debug.png

 

Your ABAP report will render within the emulator in the same way it would on a mobile device. This is a quick way to experiment and tweak your reports to make sure the correct data is being passed back and forth. It's as simple as making a minor modification to your report, activating and refreshing the browser window to see the new changes take effect!

 

Once your application looks perfect, it can be distributed to test devices for hardware integration testing. Finally, using the user authorization system, the application can be pushed to the end user devices for use in production.

 

Mobile Clients

 

Currently we are in the process of beta testing the mobile clients for Android and iOS devices. If you are interested in participating in the beta testing phase, head on over to our Google+ Community for Beta Testing. Shortly we will also be looking for beta testers with Windows Phone and Blackberry devices.

 

Links

 


Do Quality Processes really matters ?

$
0
0

"Do the Quality processes in SAP projects really matters ? ",this is  a basic question which strike to my mind,while I was sitting in the Quarterly Audit for my project."You have to update the object tracker regularly and also the defect tracker with all the efforts and if missed that will amount to Non-conformance of the quality process;The WBS of the project should be evident ;where are you putting all the efforts for TS review ? " , screamed the Auditor.

   These questions appeared to me as volleys, from which I have to safeguard my head;otherwise it would definitely strike the Head ! 

 

But do we really follow Quality processes in our projects and fill the documents in timely manner ? Or, is it simply a Historical and manipulated Data ?

And what benefit, it will provide to the project in continuous improvement ?

 

Now-a-days,in the SAP Projects - whether Implementation or Support - the environment is very challenging and more and more stressful.Every now and then there are rapid changes in the requirements and sometimes, it is seen that after the long development period of 3 months, finally the object is scrapped and it is no more required.Or otherwise, it is found that although the development is correct but the old version of the object was better;so switch to the older version  and comment the latest one ! So how you define the SDLC for this ? Within the Quality perspective,first you have to develop a technical specification or a technical design for the object and then jump to coding.But, if the requirements keeps on changing and no test data is given ? then , what should be the approach ?

 

The most favorite Question that is asked in the Audit is - "what is your delivery process ?" ."How do you deliver the object to the end customer ?" . The real problem arises when the customer do not follow any specific process and your Quality Department is adamant on following s set of processes. "We are a CMMI Level 5 company and we cannot compromise with any non-conformance of the Quality Process ", adds the QA of the project. So, how to strike a balance between the two flippers - Client and the Quality Deptt. ? Finally, what is the solution ? Is it right that you feel always overburdened with the lot of Work and always face the dilemma of managing the start data and end date of a object and its representation in the object tracker ! 

 

The quality system of a company - I feel - is to facilitate the smooth delivery to the client and definitely of High Quality.To ensure this, there must be - what we call it as adaptation- just like in Agile Development.The Quality processes should not be blindly followed,but,rather be adapted to the client requirements and delivery processes.It must not be the case of too many processes or no process.In this way,only, the QMS may  achieve its basic organisational  goal of 'High Quality Delivery" . Till this thought is put into consideration,our Team Leads and Manager will surely have a hard time with QA !

 

 

I still feel that the debate is still not over for this moot point and would certainly like to hear the voices of fellow members and their thoughts.Please feel free to share your expression on  this.

A Developers Lament

$
0
0

I think most developers will agree with the below remarks...

 

 

 

Why, oh, why do users keep raising issues to developer’s like: “It doesn’t work, can you please check it?”, and just leave it at that? No explanation, no example, nothing…

 

 

 

To all these users I would like to say:

We REALLY want to help, we truly do. But please, please, please just give us the information we need, to help you! Do not drop the question and expect us to be able to read your minds. We can debug a program, but we cannot debug you. When raising an issue, please add a clear description of what steps were taken and what the problem is.

  • What happened and what was the expected result?
  • Which transaction did you use?
  • What message was returned?
  • When did this happen?
  • Can the issue be repeated? How?

 

 

Be as clear as you can be! It may take a bit of extra effort at the start, but in the end it will save us all a lot of time.

 

 

Please guide us through the steps with patience, because we are NOT functional people and we do not (usually) know the proper business way to do what you normally do. What is obvious to you, is not obvious to us. We may not even know the right transaction… And we do not go through the screens you use.

 

We are not trying to frustrate you by asking all the questions we ask, how silly they may seem.

 

 

We just want to help! REALLY!



Okay, now I probably have developers agreeing with me on this. Having not enough information is frustrating and makes it difficult to help efficiently. The reason for me pointing at the users, is only done because developers will recognize them as a known problem. If only we could work without users... But this blog is not aimed at users, nor written for users. It is written for developers.

Let us turn it around and let it backfire...

Now, if you are a developer and you recognize this problem (you do, don’t you?), then have a look at how developers post on SCN… I see many questions, by developers, to developers, in the above mentioned user-way.


 

 

Developers keep raising issues to developer’s like: “It doesn’t work, can you please check it?”, and just leave it at that. No explanation, no example, nothing…

 

 

To all these developers I would like to say:

We REALLY want to help, we truly do. But please, please, please just give us the information we need to help you! Do not drop the question and expect us to be able to read your minds. We can debug a program, but we cannot debug you. When raising an issue, please add a clear description of what stpes were taken and what the problem is.

  • What happened and what was the expected result?
  • Which transaction did you use?
  • What message was returned?
  • When did this happen?
  • Can the issue be repeated? How?

 

 

Be as clear as you can be! It may take a bit of extra effort at the start, but in the end it will save us all a lot of time.

 

 

Please guide us through the steps with patience, because we are NOT sitting next to you and we do not (usually) know the what you did. What is obvious to you, is not obvious to us. We may not even know the right transaction… And we do not go through the screens you use.

 

We are not trying to frustrate you by asking all the questions we ask, how silly they may seem.

 

 

We just want to help! REALLY!

Netweaver 7.4 - Value Suggest in SE80

$
0
0

Hi All,

 

I came across a nice feature - Value Suggest for Object Names in SE80 transaction in Netweaver 7.4 system and would like to share you.

 

In the earlier versions of Netweaver systems (Prior to Netweaver 7.4), to search a particular object and load it in SE80, we use wild card (*) and press Enter.

1.jpg

 

Once we press enter, the result entries will be shown in the popup.

2.jpg

 

In Netweaver 7.4, Value Suggest feature is added which shows the result entries as we type it.

3.jpg

Once we select the Object(double click), the object will be loaded without the need to pressing Enter.

 

5.jpg

6.jpg

 

It even shows the result entries as we type it using wild card (*).

4.jpg

 

Looks coooool rite.!

 

I wounder whether this feature can be switched off via user parameters for some people who don't want this feature!

 

Hope this will be more improved( the value suggest result space) and the switch on/off value suggest will be added in the near future

Display an ALV in the MODULE POOL Screen

$
0
0

This Program will Show an error log containing Material No, Source Plant, Destination Plant Status etc. in ALV report which was called from a  Module POOL.

1.JPG

 

STEP 1: Declare an internal table to be displayed in ALV Report

 

This is the Detailed Structure for ERROR LOG

 

*--Types for Error Log

types: begin of ty_err_log,

        matnr type matnr ,"Material No

        from_plant  type werks_d             ,"Plant

        dest_plant  type werks_d             ,"Plant

        from_sloc   type lgort_d             ,"Str. Location

        to_sloc     type lgort_d             ,"Str. Location

        Qty         type ktmng               ,"Qty

        charg       type charg_d             ,"Batch

        msg(132) type c ,"Message

        end of ty_err_log.

 

 

*--Internal table for error Log

data: itab_err_log type standard table of ty_err_log initial size 0.

 

 

  STEP 2: create a custom control from Screen Layout (GRID_NAME)

2.JPG

 

STEP 3: create a container for custom control and assign the grid to container

 

**&---------------------------------------------------------------------

**

**&      Form sub_alv_display

**&---------------------------------------------------------------------

**

**       Calls an ALV Report

**----------------------------------------------------------------------

 

FORM sub_alv_display .

 

* Local Variable Declaration-------------------------------------------

  DATA :

*     Local Variable for Screen Container Name

       l_screen_container     TYPE scrfname VALUE c_grid_name,

       ls_stable        TYPE lvc_s_stbl.

 

* Create a Custom Container for the Subcreen

  CREATE OBJECT v_container_9300

      EXPORTING container_name = l_screen_container.

 

 

* Assign the Grid to the Custom Container

  CREATE OBJECT v_grid_9300

      EXPORTING i_parent = v_container_9300.

 

 

 

STEP 4: Populate the field catalog  and display the ALV Report (CALL METHOD v_grid_9300->set_table_for_first_display)

 

* Set the Field Catalog

  PERFORM sub_set_fieldcat.

 

* Display the values of dynamic table in screen 9003

  CALL METHOD v_grid_9300->set_table_for_first_display

    EXPORTING

      i_structure_name = 'WA_ERR_LOG'

    CHANGING

      it_fieldcatalog  = itab_fieldcat

      it_outtab        = itab_err_log.

 

  ls_stable-row = 'X'.

  ls_stable-col = 'X'.

 

  CALL METHOD v_grid_9300->refresh_table_display

    EXPORTING

      is_stable = ls_stable

    EXCEPTIONS

      finished = 1

      OTHERS = 2.

*&---------------------------------------------------------------------*

*&      Form sub_set_fieldcat

*&---------------------------------------------------------------------*

*       Populate the Filed Catalog

*----------------------------------------------------------------------*

 

FORM sub_set_fieldcat.

  REFRESH: itab_fieldcat.

 

  PERFORM sub_create_ctlg_table USING:

      '1' 'MATNR'     'ITAB_ERR_LOG' text-001 '' '18'   '' '' '' ''

'',

      '4' 'DEST_PLANT'     'ITAB_ERR_LOG' text-004 '' '14'   '' ''

'' ''

'',

 

      '2' 'FROM_PLANT'     'ITAB_ERR_LOG' text-002 '' '14'   '' ''

'' ''

'',

      '3' 'FROM_SLOC'     'ITAB_ERR_LOG' text-004 '' '14'   '' ''

'' ''

'X',

      '5' 'TO_SLOC'    'ITAB_ERR_LOG' text-005 '' '14'   '' '' ''

''

'X',

'6'  'QTY' 'ITAB_ERR_LOG' text-006 '' '17' '' '' '' ''

'X',

'7'  'CHARG' 'ITAB_ERR_LOG' text-007 '' '10' '' '' '' ''

'X',

'8'  'MSG' 'ITAB_ERR_LOG' text-008 '' '132' '' '' ''

''

'X'.

 

  1. ENDFORM.                    " create_fieldcatalog

 

**&-------------------------------------------------------------------*

**&      Form sub_create_ctlg_table

**&--------------------------------------------------------------------*

**       inserting into field catalog table

**--------------------------------------------------------------------*

FORM sub_create_ctlg_table USING  p_colpos

                               p_fldname

                               p_tabname

                               p_dispname

                               p_reftabname

                               p_len

                               p_chk

                               p_edit

                               p_key

                               p_emphasize

                               p_do_sum.

 

  DATA: wa_fieldcat TYPE lvc_s_fcat.   "work area for fieldcat

*Assign required fields into workarea

  wa_fieldcat-col_pos         = p_colpos.

  wa_fieldcat-fieldname       = p_fldname.

  wa_fieldcat-tabname         = p_tabname.

  wa_fieldcat-coltext         = p_dispname.

  wa_fieldcat-ref_table       = p_reftabname.

  wa_fieldcat-outputlen       = p_len.

  wa_fieldcat-checkbox        = p_chk.

  wa_fieldcat-edit            = p_edit.

  wa_fieldcat-key             = p_key.

  wa_fieldcat-emphasize       = p_emphasize.

  wa_fieldcat-do_sum             = p_do_sum.

  APPEND wa_fieldcat TO itab_fieldcat.

  CLEAR wa_fieldcat.

 

  ENDFORM . "sub_create_ctlg_table


XML File processing from the Application Server

$
0
0

1.0 Introduction

This document explains the parsing of the XML document residing in the application server on the DOM-based approach. The intention of this document is to describe the step by step design procedure to parse the XML document. As a result of which the XML file can be used as an input file for an inbound interface.

 

 

2.0 What is XML?

XML 1.0 is a subset of an existing, widely used international text processing standard (Standard Generalized Markup Language) intended for use on the World Wide Web. XML retains ISO 8879's basic features - vendor independence, user extensibility, complex structures, validation, and human readability - in a form that is much easier to implement and understand. XML can be processed by existing commercial tools and a rapidly growing number of free ones.

 

XML is primarily intended to meet the requirements of large-scale Web content providers for industry-specific markup, vendor-neutral data exchange, media-independent publishing, one-on-one marketing, workflow management in collaborative authoring environments, and the processing of Web documents by intelligent clients. It is also expected to find use in metadata applications. XML is fully internationalized for both European and Asian languages, with all conforming processors required to support the Unicode character set. The language is designed for the quickest possible client-side processing consistent with its primary purpose as an electronic publishing and data interchange format.

 

 

3.0 Implementation Considerations

Allowing integrating heterogeneous systems, more and more software vendors seem to realize the advantage of making their software XML-compatible. Typical implementation scenarios include EDI, workflow, e-commerce or media-independent publishing.

 

The SAP-System — providing access to these types of applications or data in more or less proprietary data formats today — is an ideal candidate to act as both a server and a client for other XML-enabled systems. All it needs is a way to give SAP applications programmatic access to XML documents.

 

 

 

 

4.0 Few Keywords related to the XML Processing

 

The Defination, Use, Structure and Integration procedures for the some keywords, related to the XML processing are discussed in this section.

 

4.1 DOM

Definition

The DOM presents documents as a hierarchy of "Node" objects that also implement other, more specialized interfaces. Some types of nodes may have child nodes of various types, and others are leaf nodes that cannot have anything below them in the document structure.

 

Use

The DOM also specifies a "NodeList" interface to handle ordered lists of Nodes, such as the children of a Node, or the elements returned by the Element:getElementsByTagName method, and also a NamedNodeMap interface to handle unordered sets of Nodes referenced by their name attribute, such as the Attributes of an Element. NodeLists and NamedNodeMaps in the DOM are "live", that is, changes to the underlying document structure are reflected in all relevant NodeLists and NamedNodeMaps. For example, if a DOM user gets a NodeList object containing the children of an Element, then subsequently adds more children to that element (or removes children, or modifies them), those changes are automatically reflected in the NodeList without further action on the user's part. Likewise changes to a Node in the tree are reflected in all references to that Node in NodeLists and NamedNodeMaps.

 

Structure

The package DOM contains the following interfaces: (1)if_ixml_att_list_decl, (2)if_ixml_attribute, (3)if_ixml_attribute_decl, (4) if_ixml_cdata_section, (5)if_ixml_character_data, (6)if_ixml_comment, (7)if_ixml_cond_dtd_section, (8)if_ixml_content_particle, (9)if_ixml_document, (10)if_ixml_document_fragment, (11)if_ixml_document_type, (12)if_ixml_element, (13)if_ixml_element_decl, (14)if_ixml_entity_decl, (15)if_ixml_entity_ref, (16)if_ixml_named_node_map, (17)if_ixml_namespace_context, (18)if_ixml_namespace_decl, (19)if_ixml_node, (20)if_ixml_node_collection, (21)if_ixml_node_filter, (22)if_ixml_node_filter_combining, (23)if_ixml_node_iterator, (24)if_ixml_node_list, (25)if_ixml_notation_decl, (26)if_ixml_pi, (27)if_ixml_pi_parsed, (28)if_ixml_pi_unparsed, (29)if_ixml_text.

 

Integration

The iXML library implements a superset of the W3C DOM Level 1 Core and XML specification as defined in the document PR-DOM-Level-1-19980818.

 

Differences between the DOM Level 1 Specification and the iXML implementation are usually:

 

1) Differences in method or interface names: The DOM specification is somehow inconsistent in naming convensions for method names and interfaces. In addition to that a few classes/interfaces had to be renamed due to the iXML extensions for the DTD representation (e.g. Notation and Entity have been renamed to NotationDecl and EntityDecl). In some instances the W3C DOM does provide direct access to attributes of classes, where iXML provides a set and get method explicitly. In order to get a consistent naming scheme, some W3C method names have been prefix with "get".

 

2)  iXML provides extensions to the W3C DOM classes and interfaces to represent the document type definition (DTD) as well. The W3C has not yet released a specification for the DOM representation of the DTD. As soon as this document becomes publicly available, the iXML interfaces might adopt the suggested methods.

 

3) In addition to NodeList and NamedNodeMap, iXML used the additional class NodeCollection. The NodeList class as defined in the W3C suggest an implementation as an iterator, whereas in a lot of cases a container or collection would be much more appropriate. For performance reasons, the iXML implementation of the DOM separates these two concepts clearly: NodeLists act as iterators over lists of consecutive nodes in the DOM tree (e.g. the child nodes of a node). NodeCollections in contrast are a set of references to arbitrary nodes, which don't have to be in a particular relation to each other. NodeCollections are - as the name suggests - used to collect references to otherwise unrelated nodes.

 

Other than that the iXML library follows the W3C DOM Level 1 specification very closely and does not deliberately introduce differences in the implementation. Everybody familiar with the W3C DOM will immediately recognize the similarities with the iXML implementation.

 

4.2 Event

Definition

The iXML library implements two modes of operation for the XML parser:

 

1) A mode in which the parser creates a DOM (document type definition) representation of the XML document and

 

2) A mode in which the parser signals the occurrence of certain logical elements in the XML document in form of so-called events as they are encountered during the parsing process. A logical element is e.g. an attribute, an element, a notation or entity declaration, a processing instruction etc.

 

Use

The Event package contains all definitions necessary for the eventing mode approach to XML parsing with the iXML library.

 

Each event can be distinguished at the two points in terms of the time:

(1) the time at which it can be told, what logical element (or node) has been found by the parser - the pre-event

(2) the time at which the complete logical element has been parsed - the post-event.

 

In addition to the distinction between pre- and post-events, there are different events for different logical elements. For each logical element or node class defined by the DOM, there is one matching event with two points in time at which it can occur. To make this concept more clear, here an example: the DOM defines a node type Attribute, which represents element attributes in an XML document. For this node type exists a matching event type with two points in time (pre and post), i.e. there is an event AttributePre and AttributePost. AttributePre is signaled, if the parser encounters an attribute in the XML input stream (i.e. when a name has been parsed in a start tag and the following character is an equal sign (=)). The event AttributePost is signaled, when the parser has finished parsing the attribute, i.e. the attribute's value has been parsed. The same concept applies to all logical elements - or node types - in a similar way.

 

Structure

The package Event contains the following interfaces: if_ixml_event.

 

Integration

An event is implemented as an interface - the iXMLEvent interface. Signaling an event to the caller means returning a reference to an iXMLEvent interface.

 

To find out what type of event an iXMLEvent interface reference represents, call iXMLEvent::getType(). This call will return the event's type.

 

For each iXMLEvent interface instance exists a corresponding DOM node instance. This DOM node stores the information that is relevant for the particular event (e.g. the name and value of an attribute). To get to the DOM node (or DOM interface to be more precise) associated with an Event interface, you can call the Event::getNode() method.

 

In order to avoid this step of indirection when accessing event related information (e.g. the element's name) a few convenience methods have been added to the Event interface: getName() to retrieve the logical element's name, getValue() to retrieve the logical element's value, getAttributes() to retrieve the associated attributes (if defined) and getParent() to find a node's parent node.

 

You have to be aware though that these methods are not always meaningful for a particular event (or associated node); e.g. calling getAttributes() on a CommentPre/Post event is undefined since comment nodes don't have attributes, or calling getValue() on a TextPre event is undefined since at this point in time the value of the Text node has not yet been parsed. To find out what information is available for each event and point in time, please refer to the Event::EventTypes documentation.

 

Calling update methods (e.g. setAttribute()) on the node associated with an event might lead to undesired and undefined results; it is therefore strongly discouraged! Calling read-only methods (e.g. Text::isWSOnly()) is allowed of course.

 

 

4.3 Stream

Definition

The stream package contains all definitions to handle XML stream I/O.

 

Input and output of XML documents is handled in terms of XML streams in the iXML library. Even though the streams used in the iXML library have a lot in common with the C++ standard streams, an independent implementation - not derived from the C++ standard streams - has been chosen for mainly two reasons:

 

(1) It should be very easy to add a new stream type (e.g. for internal/RFC tables) without having to implement the full C++ stream interface.

(2) There is only little used from the functionality of the C++ standard streams in the iXML implementation whereas on the other side a lot of other, missing functionality has to be implemented. In short: there are more differences than commonalities.

 

The stream package defines three major concepts: an XML stream factory (iXMLStreamFactory), an XML input stream (iXMLIStream) and an XML output stream (iXMLOStream).

 

Use

The stream factory is used to create XML input and output streams. Since different input sources and output destinations have to be considered, iXMLIStream and iXMLOStream interfaces will be implemented by different classes, each one capable of serving a particular source or destination. Each of these classes is registered or can be registered with the XML stream factory (prototype pattern) and can be queried about its capabilities. This allows the stream factory to create streams for all supported sources or destinations on request in an client application independent way. One of the advantages of this approach is the XML parsers capability to automatically resolve external entity references, as long as there is a stream type registered with the factory, that can handle the protocol defined by the URL.

 

Structure

The package Stream contains the following interfaces: (1)if_ixml_istream, (2)if_ixml_ostream, (3) if_ixml_stream, (4) if_ixml_stream_factory.

 

 

5.0 XML file processing from the Application Server

 

            The following steps will be used to process the XML file from the application server.

 

5.1 Read the XML file in the binary mode

 

Read the XML file from the application server in the binary mode and store in the internal table in the hexadecimal format.

 

* Open the XML file of the application server.

  OPEN DATASET g_physical_path FOR INPUT IN BINARY MODE.

 

  IF sy-subrc = 0.

* Read the XML file of the application server.

    DO.

      READ DATASET g_physical_path INTO l_xml_line-data.

“The line is of type ‘X’ and of length 256.

      IF sy-subrc = 0.

 

        APPEND l_xml_line TO g_t_xml_table.

        CLEAR:l_xml_line.

 

* Count the number of entries.

        g_xml_table_size = g_xml_table_size + 1.

ELSE.

        EXIT.

      ENDIF.

    ENDDO.

CLOSE DATASET g_physical_path.

  1. ENDIF.

 

* Calculate the File Size.

  g_xml_table_size = g_xml_table_size * 256.

 

The file size will be used in the later part of the processing.

 

 

5.2 Create the document to hold the DOM tree

 

            Create a DOM representation of an XML document as follows:

You will need the cl_ixml main factory. In addition to that we will need a cl_ixml_stream_factory object to create the input stream. Then place the DOM-tree into the cl_ixml_document object.

 

* Create the main iXML factory.

  g_ixml = cl_ixml=>create( ).  “g_ixml TYPE REF TO if_ixml.

 

* Create a stream factory.

g_streamfactory = g_ixml->create_stream_factory( ). 

“g_streamfactory   TYPE REF TO if_ixml_stream_factory

 

 

* Wrap the table containing the file into a stream.

  g_istream = g_streamfactory->create_istream_itable( table = g_t_xml_table

size = g_xml_table_size ).

                                                “g_istream TYPE REF TO if_ixml_istream

 

* Create the document.

g_document = g_ixml->create_document( ). “g_document TYPE REF TO if_ixml_document

 

 

 

5.3 Parse the XML document in the DOM-based approach

 

            The XML document can be parsed in two ways: either creating a DOM representation of the XML document, or by the parser firing events as logical elements are encountered in a run through an XML document. The DOM-based parsing is discussed here.

 

In order to parse the document, you will also need a cl_ixml_parser object. The Parser can be obtained from the iXML factory by the following call.

* Create the Parser.

  g_parser = g_ixml->create_parser( stream_factory = g_streamfactory

                                                                 istream  =  g_istream

                                                             document  = g_document ).

                                                                                “g_parser type ref to if_ixml_parser

 

A cl_ixml_parser object is a "use once and throw away" object. That means that you create a new cl_ixml_parser, call it to parse one document and then throw the parser object away. There is no way of reusing the parser for an additional XML document.

Our goal was to parse an XML document into a DOM tree, so here we go now:

g_parser->parse( ).

If there haven't been any errors in the XML document we just parsed from the input stream provided, then the document object we passed to the factory method of the parser will now contain the DOM representation we were looking for.

Since errors usually happen, we should try to play this game a little bit safer, do some error checking and print out diagnostic messages:

 

DATA: parseerror TYPE REF TO if_ixml_parse_error,

            str        TYPE string,

            i          TYPE i,

            count      TYPE i,

            index      TYPE i.

 

 

* Parse the stream.

  IF g_parser->parse( ) NE 0.

IF g_parser->num_errors( ) NE 0.

 

      count = g_parser->num_errors( ).

     WRITE: count, ' parse errors have occured:'.

      index = 0.

      WHILE index < count.

        parseerror = g_parser->get_error( index = index ).

        i = parseerror->get_line( ).

       WRITE: 'line: ', i.

        i = parseerror->get_column( ).

       WRITE: 'column: ', i.

        str = parseerror->get_reason( ).

        WRITE: str.

        index = index + 1.

      ENDWHILE.

    ENDIF.

  1. ENDIF.

 

Now the cl_ixml_document object can be used for the further processing.

 

 

5.4 Traverse the DOM tree with iterators

 

            Iterators have the important features when used with the DOM:

1. They provide a consistent interface for access the different data structures

2.They allow to hide the internal workings of the data structures they work on

3. By doing so they allow to implement iterator-internal optimizations to utilize specific aspects of the data structure over which they iterate.

 

To traverse the complete DOM-tree in an DFS (Depth-First-Search) traversal, you can use an iterator created on an cl_ixml_document object. If you want to iterate over any sub-tree of the document, simply create the iterator on the root node of the sub-tree over which you want to iterate.

Once you have obtained the iterator, you can repeatedly call the if_ixml_node_iterator::get_next() method until null is returned, which signals the iteration has come to an end.

 

DATA: iterator TYPE ref to if_ixml_node_iterator,

             node TYPE ref to if_ixml_node.

 

iterator = document->create_iterator( ).

node = iterator->get_next( ).

 

while not node is initial.

* Process the node values.

  ...

  node = iterator->get_next( ).

  1. endwhile.

Sometimes you want to restrict the depth of the traversal. You can do so by passing the factory method of an iterator an additional depth parameter as in the following example, which will only iterate the level immediately below the cl_ixml_element instance.

DATA: iterator typeref to if_ixml_node_iterator.

iterator = element->create_iterator( 1 ).

 

 

 

 

6.0 Example

The requirement is taken from the object ‘AP2PLE-AP-TDD-E-10’ of the ‘Johnson & Johnson, Lynx Cornerstone’ project. The requirement was to upload a XML file from the application server, which contains the bank records. Then the bank records got posted in SAP using the BAPI ‘BAPI_BANK_CREATE’ and the bank records got changed in SAP using the BAPI ‘BAPI_BANK_CHANGE’.

 

The code dump is attached here to populate the bank records into the internal table from the XML file of the application server. Then the internal table can be used as per the requirement.

 

The test file with the bank records is also attached here and the content of the internal table is shown in the report format for the reference.

1.JPG

2.JPG


Viewing all 948 articles
Browse latest View live


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