quarta-feira, 8 de junho de 2022

Pack Handling Units App using SAP AppGyver (No-Code Challenge)

 SAP AppGyver is in my to-learning list since its beginning. I started with SAP Fiori in 2015 and lived the BUILD age. I worked with BUILD in real life projects,  and I wanted to catch up on the new prototyping tools.

Purpose

In this article I will describe my experience using SAP AppGyver for the No-Code Challenge. SAP AppGyver is SAP’s No-Code / Low-Code Platform. The challenge details are described here:

 

My App – Pack Handling Units

You can find the web version of Pack Handling Units app here:

This app aims to help warehouse clerks to pack handling units and do stock transfer using mobile device and  barcode scanner. 

A common activity in warehouses is to pack handling units (HUs) in boxes, pack boxes in pallets, and transfer these package to a staging point to be loaded onto the transport truck. 

In SAP S/4HANA, transaction HU02 is used to pack hadling units, and transaction LT10 is used to do bin-to-bin transfer. The warehouse clerk needs to do the physical pack, write the handling unit codes in a paper, and then go to desktop and use the SAP GUI transactions to do the pack and transfer in the system. Now a mobile device can be used to do the pack and transfer in real-time!

I have separated this project in 2 apps, Pack Handling Units and Stock Transfer. My entry contains the Pack Handling Units App.

 

The first page contains 2 buttons: Pack HUs and Display Packages

Pack HUs button navigates to a page to insert barcode numbers. It is possible to scan barcodes using mobile camera, or type the text manually in the input field.

The code read is inserted into the list, showing the barcode number and material description.

When a list item is clicked , the app navigates to a barcode details screen, calls an API to retrieve barcode details, and shows some details about the material. A button for delete this record is available.

Back to the page to insert barcode numbers, this page also contains a button to Pack Handling Units (same as HU02 transaction)

Pressing this button, a Package is created, and the app navigates to a page that shows a list of created Packages. This page is also showed when clicking in Display Packages button, in the first page.

The package is deleted when the line item is clicked

The next challenge for me is to insert all the read barcodes inside this package, and create a header-items hierarchy.

And I also want to know how to exclude all itens with one action, and exclude only selected lines of a list.

 

My Experience

I started in AppGyver with the built-in tutorials in Composer only. The tutorials are easy and can be completed quickly. After finishing the built-in tutorials I just started my prototype using my BUILD experience, developer experience and intuition. 

I had already created this Pack Handling Units and Stock Transfer app using SAPUI5 Freestyle, so my objective was to replicate it in AppGyver.

In this process I learned how to work with query parameters and Data Variables initialization in AppGyver, and the search for a public API increased my API knowledge significantly! 

I worked with these APIs. Some of them I played in POSTMAN, others I added in AppGyver. My first idea was use an API to retrieve material description by barcode, and other API to retrieve images by material description. 

 

https://www.barcodelookup.com/api

https://www.nutritionix.com/business/api

https://rapidapi.com/GoodFoods/api/search-grocery-product-reviews-by-barcode

https://rapidapi.com/contextualwebsearch/api/web-search

 

After finishing my prototype I wished a bigger barcode database with more product Images, so I found Open Food Facts API. And while searching for how to use URL replacements in AppGyver, I came across the getting started tutorial mentioned in challenge´s page, that uses this same API. 

At first I was shocked by the coincidence, because I really believed I was creating something new. Even though this tutorial is mentioned on the contest page, I finished my project without having read it. I started my project only with Composer built-in tutorials and found the “getting started tutorial” by chance after finish my project, because I decided to switch from Nutritionix API to Open Food Facts API.

But then I was proud of myself for having managed to create an equivalent solution on my own, with some improvements. The learning curve is different between following a tutorial and intuitively creating the solution on your own. I already feel like a winner in my personal growth.

If I had read this tutorial before doing my project, my motivation to continue with this use case would probably have been affected.

And the target user is different, then this solution might be innovative for this user.

Regarding the logic, the Data Variables looks like SAPUI5 OData Models, and I liked to work with them. The page parameters also looks like SAPUI5 routing and navigation. But I am curious to see how many time non-developers will need to understand the difference between page variables and page parameters.

While playing with logic for Pack, I could see the power the AppGyver has, providing the option to insert your own javascript logic.  And I keep this topic as a topic for further study. I believe i will need to use javascript to create some logics for header-items hierarchy.

Conclusion 

 

The BUILD experience , developer experience and MIT App Inventor experience helped me  to intuitively find the functionalities and understand them, like the different variable types, Input and output parameters, the logic tab, and API management.

But I am curious the see the learning experience of non-developers. I believe it will be necessary to at least have some concept of programming logic to do something other than the very basic.

I really want to learn how to work with loops and indexes in data collections, and do features such as deleting all items in a list with just one button, or deleting only the marked lines.

I noticed that the web version of the app does not open the camera through the browser, both in the Composer preview and in the built website. I think this is a limitation to be adjusted, because the use of the camera by the browser is already common.

I used the style options, but so far the UI looks very simple for a professional application. I may need to explore the component market further to create apps with a more professional UI.

But even so, I realized that the app is a tool that has a future. In the past I chose to delve into SAP Fiori and today I am reaping the rewards. And today I’m going to choose to delve into AppGyver because I believe this tool will be a success!


Source: https://blogs.sap.com/2022/06/02/pack-handling-units-app-using-sap-appgyver-no-code-challenge/

You used to use SE16/SE16N and SQVI, Try SE16H!

 

As you know, SAP HANA comes with many enhancements and features. The new transaction SE16H comes with new features which enables rapid tables check and small queries.

SAP Consultants used to use the transactions code SE16/SE16N/SQVI to check table’s value and/or extract data.

The transaction code SE16H enables:

  • Tables check (consult and extract) like a classical SE16 or SE16N
  • Joint creation for small query
  • Rapid check of number of entries

Here are two cases where this new features are explained

1- Complete accounting document query

Imagine a scenario where you want to check entries for complete accounting document. We can combine many finance tables, but for this example, we will only use two tables:

  • BKPF: Header data of accounting segment
  • BSEG: Accounting document segment

Launch SE16H with BSEG and create a join

Enter the criteria for your join

As described below, to have a complete finance document informations, we will add the table BKPF as a join. Then, we will click on the yellow arrow to add the fields we want to add to the output.

Please note that, as it is shown in this figure, you can apply filters on the fields you need. In this example, we have put filter on fiscal year, company code and posting month. For these filters, we have putted a constant value. But SE16H offers also other methods as displayed below.

After executing the SE16H with the joint we have created, your financial data are displayed as below.

Please note that a layout have been used for the displayed result

The fields displayed contain data from the header table BKPF and data from accounting document segment. For example, here are some field’s detail.

2- Rapid check of entries number

Group feature

In case we want to have a quick view of the number of accounting entries by company code, we have to tick the field group as indicated below and execute.

Group and sort feature

In case we want to have a quick view of number of document type used in the system for a single company code

Source: https://blogs.sap.com/2022/01/20/you-used-to-use-se16-se16n-and-sqvi-try-se16h/

terça-feira, 31 de maio de 2022

Extending GOS with Create Multiple Attachment

 Overview

Intent of this blog post is provide a working prototype for additional GOS service to upload multiple attachment together in one go.

Business Requirement

Some time it is difficult for users to upload 7-8 documents in GOS using the option ‘Create Attachment’, as the same steps needs to be repeated several times. So users require a new option ‘To upload multiple attachments from GOS’ to avoid repetitive steps.

Solution

To add a new service in GOS toolbar. we need to add an entry in table ‘SGOSATTR‘. Since we are gonna create option for multiple attachments. Below steps indicate how to add new option in GOS for multiple attachment as ‘Create Multiple Attachment’.

New%20Service%20Create%20Multiple%20Attachment

New Service Create Multiple Attachment

Follow below steps to have new service under Create option as Create Attachment Multiple

  1.  Go to SM30 T-code and open table ‘SGOSATTR’. You will see something like this.Table%20View%20SGOSATTR
  2. Now double-click on record named ‘PCATTA_CREA’. This option is nothing but the ‘Create Attachment’ under ‘Create’ option.Create%20Attachment%20option%20details
  3. Now click on the ‘Copy As’ button/F6 next to ‘New Entries’ and update it according to below image. Update the ‘Name of service‘ as per you and mainly update ‘Class f.Gen.Service‘ to ‘ZCL_GOS_SERVICE‘ new ABAP class from T-code ‘SE24’ and update the ‘Next Service to ‘RESUBMISSION‘. Make sure to unflag both ‘Control‘ and ‘Commit Required‘.Create%20Attachment%20Multiple%20option%20detailsFor details of each option refer to link 1 in reference section
  4. Now Double Click on option ‘BARCODE‘ in the table and Update ‘Next service’ option to ‘PCAT_CREA_M‘ this is the name for Service ‘Create Attachment Multiple’, so that it is visible after the ‘Enter Bar Code‘ option under ‘Create‘ option in GOS.BARCODE%20option%20details
  5. Now edit the ABAP class ‘ZCL_GOS_SERVICE‘ which we have created in step 3. Inherit the class ‘CL_GOS_SERVICEZCL_GOS_SERVICE
  6. Now go to Methods tab and redefine the method ‘Execute’ and add the following code in the method.Methods
        ##NEEDED
        DATA: lt_file_table  TYPE filetable,
              lv_rc          TYPE i,
              lv_action      TYPE i,
              lv_len         TYPE so_doc_len,
              lt_content     TYPE soli_tab,
              ls_fol_id      TYPE soodk,
              ls_obj_id      TYPE soodk,
              ls_obj_data    TYPE sood1,
              lt_objhead     TYPE STANDARD TABLE OF soli,
              lv_ext         TYPE string,
              lv_fname       TYPE string,
              lv_path        TYPE string,
              lv_path1       TYPE string,
              lv_filename    TYPE string,
              ls_note        TYPE borident,
              lv_ep_note     TYPE borident-objkey,
              ls_object      TYPE borident,
              lo_objhead     TYPE REF TO cl_bcs_objhead,
              lv_object_type TYPE soodk-objtp,
              lv_put_to_kpro TYPE sonv-flag,
              lv_filetype    TYPE rlgrap-filetype.
    
    *   import multiple files from PC
        CALL METHOD cl_gui_frontend_services=>file_open_dialog
          EXPORTING
            window_title            = 'Import Files' ##NO_TEXT
            initial_directory       = 'c:\'
            multiselection          = 'X'
          CHANGING
            file_table              = lt_file_table
            rc                      = lv_rc
            user_action             = lv_action
          EXCEPTIONS
            file_open_dialog_failed = 1
            cntl_error              = 2
            error_no_gui            = 3
            not_supported_by_gui    = 4
            OTHERS                  = 5.
        ##NEEDED
        IF sy-subrc <> 0.
    *     Implement suitable error handling here
        ENDIF.
    
    *   Logic to add to multiple attachments
        LOOP AT lt_file_table ASSIGNING FIELD-SYMBOL(<lfs_file>).
          CLEAR: lv_path, lv_filename, lv_fname, lv_ext, lv_len, lt_content, ls_fol_id,
                 ls_obj_data, ls_obj_id, ls_note, lo_objhead, lv_object_type,lv_put_to_kpro,
                 lv_filetype, lt_objhead .
          lv_path = <lfs_file>-filename.
          TRY .
    *         method to split directory and filename
              cl_bcs_utilities=>split_path( EXPORTING iv_path = lv_path IMPORTING ev_path = lv_path1 ev_name = lv_filename ).
    *         method to split filename to name & extension
              cl_bcs_utilities=>split_name( EXPORTING iv_name = lv_filename IMPORTING ev_name = lv_fname ev_extension = lv_ext ).
            CATCH cx_bcs.
              CLEAR: lv_path,lv_path1,lv_filename, lv_fname, lv_ext.
          ENDTRY.
    
          IF lv_path IS NOT INITIAL.
            CALL FUNCTION 'SO_OBJECT_UPLOAD'
              EXPORTING
                filetype                = lv_filetype
                path_and_file           = lv_path
                no_dialog               = 'X'
              IMPORTING
                filelength              = lv_len
                act_filetype            = lv_filetype
                act_objtype             = lv_object_type
                file_put_to_kpro        = lv_put_to_kpro
              TABLES
                objcont                 = lt_content
              EXCEPTIONS
                file_read_error         = 1
                invalid_type            = 2
                x_error                 = 3
                object_type_not_allowed = 4
                kpro_insert_error       = 5
                file_to_large           = 6
                OTHERS                  = 7.
            ##NEEDED
            IF sy-subrc <> 0.
    *         Implement suitable error handling here
            ENDIF.
    
            lo_objhead = cl_bcs_objhead=>create( lt_objhead[] ).
            lo_objhead->set_filename( lv_filename ).
            lo_objhead->set_format( lv_filetype ).
            lo_objhead->set_vsi_profile( cl_bcs_vsi_profile=>get_profile( ) ).
            lt_objhead[] = lo_objhead->mt_objhead.
    
    *       get the folder id where to add attachment for the BO
            ##FM_SUBRC_OK
            CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
              EXPORTING
                region    = 'B'
              IMPORTING
                folder_id = ls_fol_id
              EXCEPTIONS
                OTHERS    = 1.
            ##NEEDED
            IF sy-subrc <> 0.
    
            ENDIF.
    
    
            ls_obj_data-objdes   = lv_fname.
            ls_obj_data-file_ext = lv_object_type.
            ls_obj_data-objlen   = lv_len.
            IF NOT lv_put_to_kpro IS INITIAL.
              ls_obj_data-extct = 'K'.
            ENDIF.
    
    *       add the attachment data to the folder
            ##FM_SUBRC_OK
            CALL FUNCTION 'SO_OBJECT_INSERT'
              EXPORTING
                folder_id             = ls_fol_id
                object_type           = 'EXT'
                object_hd_change      = ls_obj_data
              IMPORTING
                object_id             = ls_obj_id
              TABLES
                objhead               = lt_objhead
                objcont               = lt_content
              EXCEPTIONS
                active_user_not_exist = 35
                folder_not_exist      = 6
                object_type_not_exist = 17
                owner_not_exist       = 22
                parameter_error       = 23
                OTHERS                = 1000.
            ##NEEDED
            IF sy-subrc <> 0.
    
            ENDIF.
    
            ls_object-objkey  = gs_lporb-instid.
            ls_object-objtype = gs_lporb-typeid.
            ls_note-objtype   = 'MESSAGE'.
    
            CONCATENATE ls_fol_id-objtp ls_fol_id-objyr ls_fol_id-objno ls_obj_id-objtp ls_obj_id-objyr ls_obj_id-objno INTO ls_note-objkey.
    
    *       link the folder data and BO for attachment in gos
            ##FM_SUBRC_OK
            CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
              EXPORTING
                obj_rolea    = ls_object
                obj_roleb    = ls_note
                relationtype = 'ATTA'
              EXCEPTIONS
                OTHERS       = 1.
            ##NEEDED
            IF sy-subrc <> 0.
    
            ENDIF.
          ENDIF.
        ENDLOOP.
        IF lt_file_table IS NOT INITIAL .
          MESSAGE s043(sgos_msg).
          go_model->set_check_atta_list( ).
        ELSE.
          MESSAGE s042(sgos_msg).
        ENDIF.
  7. If you want this new option to enabled for only certain T-codes, then redefine method ‘CHECK_STATUS‘ and additional code for enable/disable based on conditions.

for more details regarding methods to redefine and inheritance refer link 2 in reference section

Output:

Now you will get new option in GOS as below.

New%20Service

 

When you click on the new option, you can select multiple documents and upload it together.

 

GOS Attachment list.

Conclusion:

We can create a new GOS service for uploading multiple documents together by adding an entry in Table ‘SGOSATTR’ and also by inheriting the class ‘CL_GOS_SERVIVE’ in your class and redefining method ‘EXECUTE’.

References:

Link 1: http://zevolving.com/2008/10/generic-object-services-gos-toolbar-part-1-add-new-option-in-the-toolbar/

Link 2: http://zevolving.com/2008/11/generic-object-services-gos-toolbar-part-2-handle-added-service-in-the-toolbar/

 

Hope you guys liked this blog post.

Feel free to comment, like and share.


Source: https://blogs.sap.com/2022/04/04/extending-gos-with-create-multiple-attachment/