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

Programs holding its own documents - "Stop running to find the documents".

$
0
0

Purpose : The idea of this documentation concept is to make your programs have their own documents in SAP system itself,which helps the developer who makes changes to the program in future.Even helps a layman to understand what the program does and what for the program is done.

 

Idea Behind : The idea behind this Blog is to give an idea to the developers how to make their program hold their own documents.Usually in our daily routine developers and functional consultants searching the person who developed that object.

 

Advantages :

 

1. No need to maintain the documents in a share folder or in a different repository.

 

2. Since this can be created as a Function module or subroutine it can be used in any of the programs.

 

3.It Supports most of the commonly used formats like DOC,XLS,PDF and more like JPG, JPEG.

 

4.Last but not least "It is also transportable to other landscapes like Quality and Prod.

 

 

Procedure:

 

In this blog i will take you to the process in 5 quick steps.

 

Step 1:

 

Run the transaction OAOR or execute the program BDSFIND_1.

 

The selection screen looks like this:

selection screen.png

In this enter

class name  : pictures.

class type  : OT (other type of objects).

object key : Enter your Program or object name.

 

Then Execute (F8).

 

STEP 2 :

 

Executing that we will get a screen like below.In that expand the standard document types menu.

standard doc types.png

In that double click the attachment or Text because we are going to add the word documents related to the program (TS & FS).

 

Then it will allow you to import file from your local machine,then select the file and give open.

browse.png

Then You could give the Short Description for the Documents in the next screen.

short decription.png

 

Like the above step we added the Technical Specification document also.We can see the added documents by clicking on text tree.

display.png

Now the step 2 is been completed. we have  successfully  added our documents to the SAP system.

 

Step 3:

Now the File is been added to the SAP system.If you want the file to be transported to the Quality and Production system then follow the below step by creating a TR or adding it to an existing TR.

 

Check the check boxes of the documents that you want to transport and click on documents-->Transport.

 

It will prompt you to transfer all the selected documents,click yes then will ask for TR.

 

You could create a new TR or assign it to an open TR.It is advisable to use the same TR of the program to which you want to display the documents.

 

tr.png

Enter the TR details,then it will be ready to be transported.

 

Step 4:

 

Linking this file to your program and make it available to view while executing the program.

 

use the following code:


 

report ZDOCUMENTATION_HELP.

 

*---Data Declaration.

 

DATA: t_signat LIKE bapisignat OCCURS 0 WITH HEADER LINE,

       t_compon LIKE bapicompon OCCURS 0 WITH HEADER LINE,

       v_doccnt TYPE char08, "bds_dcount,

       v_choice TYPE char300,

       v_answer TYPE c.

 

*---selection screen design for the help icon.

SELECTION-SCREEN BEGIN OF BLOCK doc_help WITH FRAME TITLE text-a00.

SELECTION-SCREEN PUSHBUTTON /1(20) but1 USER-COMMAND call_help VISIBLE LENGTH 24.

SELECTION-SCREEN END OF BLOCK doc_help.

 

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

*              AT SELECTION SCREEN OUTPUT - PBO

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

 

*---Here with the below function module in the At selection-screen output

*   event we create an icon in the selection screen where by clicking that

*   it will show the documents we added in the system.

 

 

AT SELECTION-SCREEN OUTPUT.

 

*---To create an icon in selection screen.

 

   CALL FUNCTION 'ICON_CREATE'

     EXPORTING

       name                  = 'ICON_SYSTEM_HELP'

       text                  = 'Tech Details'

       add_stdinf            = 'X'

     IMPORTING

       RESULT                = but1

     EXCEPTIONS

       icon_not_found        = 1

       outputfield_too_short = 2

       OTHERS                = 3.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

 

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

*               AT SELECTION SCREEN - PAI                            *

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

 

*---Here we are linking the user command of this help buton to fetch the

*   the data from the SAP system.

 

AT SELECTION-SCREEN.

 

*---If the push button is clicked call the Help Files

   CASE sy-ucomm.

 

     WHEN 'CALL_HELP'.

 

       CLEAR: v_choice, v_answer, v_doccnt.

 

*---Call the program to process HELP Files

*---Read document details

       CALL FUNCTION 'BDS_BUSINESSDOCUMENT_GET_URL'

         EXPORTING

           classname                        = 'PICTURES'

           classtype                        = 'OT'

           client                           = sy-mandt

           object_key                       = 'ZDOCUMENTATION_HELP'

           url_lifetime                     = 'T'

         TABLES

           signature                        = t_signat

           components                       = t_compon

         EXCEPTIONS

           nothing_found                    = 1

           parameter_error                  = 2

           not_allowed                      = 3

           error_kpro                       = 4

           internal_error                   = 5

           not_authorized                   = 6

           OTHERS                           = 7

                 .

       IF sy-subrc <> 0.

*        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

       ENDIF.

 

       IF sy-subrc = 0.

 

*---To Display the Pop up with all document information.

 

         CALL FUNCTION 'POPUP_WITH_TABLE'

           EXPORTING

             endpos_col   = '80'

             endpos_row   = '10'

             startpos_col = '4'

             startpos_row = '5'

             titletext    = 'Double CLICK the HELP file to OPEN'

           IMPORTING

             choice       = v_choice

           TABLES

             valuetab     = t_compon

           EXCEPTIONS

             break_off    = 1

             OTHERS       = 2.

         IF sy-subrc <> 0.

*          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

 

           MESSAGE  'User CANCELLED Processing' TYPE 'S'.

*---There are situations after the BDS Call the program hangs,to avoid that.

 

           SUBMIT zdocumentation_help VIA SELECTION-SCREEN.

         ELSE.

 

           IF v_choice IS INITIAL.

 

             MESSAGE  'User CANCELLED Processing' TYPE 'S'.

*---There are situations after the BDS Call the program hangs,to avoid that.

 

             SUBMIT zdocumentation_help VIA SELECTION-SCREEN.

 

           ELSE.

 

             MESSAGE  'Opening SELECTED file' TYPE 'I'.

 

           ENDIF.

 

         ENDIF.

 

*---Process data

         v_doccnt = v_choice.

         SORT t_signat BY doc_count.

         READ TABLE t_signat WITH KEY doc_count = v_doccnt.

 

*---Open the selected document

         CALL FUNCTION 'BDS_DOCUMENT_DISPLAY'

           EXPORTING

             client                = sy-mandt

             doc_id                = t_signat-doc_id

           EXCEPTIONS

             nothing_found         = 1

             parameter_error       = 2

             not_allowed           = 3

             error_kpro            = 4

             internal_error        = 5

             not_authorized        = 6

             OTHERS                = 7

                   .

         IF sy-subrc <> 0.

*          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

         ENDIF.

 

*--Again after HELP File is displayed, call back the program to prevent slowing down or hanging issues

         SUBMIT zdocumentation_help  VIA SELECTION-SCREEN.

       ENDIF.

 

     WHEN OTHERS.

 

   ENDCASE.


 

Step 5:

Then execute the code the selection screen looks like the below screenshot.

 

selection.png

Click on the TECH DATA icon which we created through our code.

 

a popup appears like below,there select Tech spec or functional spec whatever you want to view.

 

spec.png

Here i have selected the Tech spec and clicked ok.

 

The Word document for Tech spec which we uploaded in the SAP system will be opened like below.

 

doc.png

 

we are done...

 

 

We can add the rest part of our code so that the documents explaining about that code can be stored here.

 

Hereafter no need to maintain the documents in a different repository,just have it with your program itself.

 

 

Enjoy....

 

Thanks,

Dinesh.



Viewing all articles
Browse latest Browse all 948

Trending Articles



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