cancel
Showing results for 
Search instead for 
Did you mean: 

Does Subroutine works in WDA ?

former_member190689
Contributor
0 Kudos

Hello Gurus,

     I have created a WDA in which user selects the material number through select-option and as he clicks on SUBMIT the remaining data required will be displayed. Now , if the user wants to change any field like MAKTX(Description) and then clicks on SAVE , the whole data is saved in ztable. But only the changed row is being saved

    At the same time I have created a change document number and I am using it in my program. with syntax

PERFORM number_generation IN PROGRAM znumber_generation.

  But its not working. I debugged the code and saw that compiler goes into the perform and generates the number as also saves the number in the required destination but when the debugger goes to the next code , the number saved in CHANGE_DOC_NO is lost.

  1. Does subroutine works in wda? if so , how ? Am I doing something wrong ?

2. When user clicks on SAVE .With the help of change_doc_no which is unique in ztable will help to see the rest of the ztable holding the changed data.

Below is the code which I wrote under number_generation.


DATA:    CHANGE_DOC_NO       TYPE AENNR.


  FORM number_generation.
       DATA: l_object TYPE nrobj.

*      *Different intervals for gate entry not allowed and gate entry
*allowed
   l_object = 'ZMAT_DET1'.
*Number range: Lock object
       CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
         EXPORTING
           OBJECT                 = l_object
        EXCEPTIONS
          FOREIGN_LOCK           = 1
          OBJECT_NOT_FOUND       = 2
          SYSTEM_FAILURE         = 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.
       ENDIF.

*NUmber range: Assigns next free number
   CALL FUNCTION 'NUMBER_GET_NEXT'
     EXPORTING
       nr_range_nr                   = '01'
       object                        = l_object
      quantity                      = '1'
*   SUBOBJECT                     = ' '
*   TOYEAR                        = '0000'
*   IGNORE_BUFFER                 = ' '
    IMPORTING
      number                        =  CHANGE_DOC_NO
*   QUANTITY                      =
*   RETURNCODE                    =
    EXCEPTIONS
      interval_not_found            = 1
      number_range_not_intern       = 2
      object_not_found              = 3
      quantity_is_0                 = 4
      quantity_is_not_1             = 5
      interval_overflow             = 6
      buffer_overflow               = 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.
   ENDIF.

*Number range: Unlock object
   CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
     EXPORTING
       object           = l_object
     EXCEPTIONS
       object_not_found = 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.
   ENDIF.

   

Thanks in Advance

Gaurav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Since the form is in a custom program, why not just create it in a static method? The static method can call the FORM. This way it is cleaner and adheres to the OO programming guidelines.

former_member190689
Contributor
0 Kudos

Hello Abdullah ,

       As per my code , I have created a zprogram for subroutine and I have used the statement for calling in my WDA.

My main concern is when Debugger reach to the perform code it executes the code very well but when it comes out of the perform to display the message.The change_doc_no where the number is being hold is lost.

I hope now you must have a clear idea what am I up to ?

  Thanks in advance

Gaurav Gautam

Former Member
0 Kudos

Just convert the FORM to a static METHOD. With very small modifications, you can pretty much copyt the whole form as is into the body of a method.

Answers (5)

Answers (5)

Former Member
0 Kudos

One thing you need to keep in mind, the FORM you wrote does not have any parameters. Create a CHANGING parameter that returns the generated number back to the calling code (whether WDA method or any other piece of code).

Former Member
0 Kudos

Hi Gaurav,

Please check this..

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

Cheers,

Kris.

former_member190689
Contributor
0 Kudos

Hi Kris,

    Thanks for the thread.But as per my requirement I have to provide a change_doc_number for every changes made to the material related data.Could you please tell me any other possible way by which I can create so.As I did through creating a zprogram..look to below code.

DATA:    CHANGE_DOC_NO       TYPE AENNR.


  FORM number_generation.
       DATA: l_object TYPE nrobj.

*      *Different intervals for gate entry not allowed and gate entry
*allowed
   l_object = 'ZMAT_DET1'.
*Number range: Lock object
       CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
         EXPORTING
           OBJECT                 = l_object
        EXCEPTIONS
          FOREIGN_LOCK           = 1
          OBJECT_NOT_FOUND       = 2
          SYSTEM_FAILURE         = 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.
       ENDIF.

*NUmber range: Assigns next free number
   CALL FUNCTION 'NUMBER_GET_NEXT'
     EXPORTING
       nr_range_nr                   = '01'
       object                        = l_object
      quantity                      = '1'
*   SUBOBJECT                     = ' '
*   TOYEAR                        = '0000'
*   IGNORE_BUFFER                 = ' '
    IMPORTING
      number                        =  CHANGE_DOC_NO
*   QUANTITY                      =
*   RETURNCODE                    =
    EXCEPTIONS
      interval_not_found            = 1
      number_range_not_intern       = 2
      object_not_found              = 3
      quantity_is_0                 = 4
      quantity_is_not_1             = 5
      interval_overflow             = 6
      buffer_overflow               = 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.
   ENDIF.

*Number range: Unlock object
   CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
     EXPORTING
       object           = l_object
     EXCEPTIONS
       object_not_found = 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.
   ENDIF.

Could you please tell me any other way to create the change_doc_number as also to use in my WDA.

Thanks and Regards

Gaurav Gautam

Former Member
0 Kudos

Hi Gautam,

Kindly check any BAPI or FM is there for your requirement.

you want to generate doc_no on every change? using 'NUMBER_GET_NEXT' you can generate one number on every change.

For EX : write your NUMBER_GET_NEXT code in chage button. After doing all changes in layout

click this button it will generate and gives a new number and using that you can save data to database.

But, i think generates new no on every change is not a correct way. Check once and try this.

Cheers,

Kris.

former_member183224
Participant
0 Kudos

Hi Gaurav,

Yes WDA is OOPS based. So you can not use internal subroutines.

But you can call any subroutines externally and use the same.

Regards,

Gourav

m_aravindan
Active Participant
0 Kudos

Hi Gaurav,

              Sub routine does not work in webydnpro , Since webydnpro is OOPS based.

Regards
Aravindan

former_member183224
Participant
0 Kudos

Hi Gaurav,

Yes you can use subroutines in WDA.

You can very well use PERFORM statement in any Class method or WDA method. You need to just create a executable program (eg testprogram) and include those subroutines in that program. Now in your WDA method, write the following line:

PERFORM subroutine_name IN PROGRAM testprogram USING ... CHANGING .....

Hope it helps. Reward point if useful.

Thanks,

Gourav