Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with multiple Call to Submit statement in a Program.

Sijin_Chandran
Active Contributor
0 Likes
1,091

Hello All ,

I have created a ZPROGRAM which call KSB1 Program in it using SUBMIT statement .

The call is executed period wise.

Eg . if user inputs the value for period as 02 - 04 , then inside Case statement first call to KSB1 using SUBMIT will be done for period 02 after that 03 and then 04.

for the first execution i.e for period 02 the data is coming as expected but after that for 03 no data is coming , but when I am executing KSB1 externally for Period 03 data is there.

So SUBMIT is not working properly for the second time in the same session.

Can anyone tell me whats the matter and how can I solve this issue.

Code snippet :

CASE VAR_PERIO.

         WHEN '001'.

          CALL FUNCTION 'G_POSTING_DATE_OF_PERIOD_GET'

             EXPORTING

               PERIOD                    = '001'

               VARIANT                   = 'V3'

               YEAR                      = P_GJAHR

            IMPORTING

              FROM_DATE                  = RA_DATUM-LOW

*            LAST_NORMAL_PERIOD         =

              TO_DATE                    = RA_DATUM-HIGH

*            FROM_DATE_ORIG             =

                   .

               IF SY-SUBRC EQ 0.

                 RA_DATUM-SIGN = 'I'.

                 RA_DATUM-OPTION = 'EQ'.

                 APPEND RA_DATUM.

               ENDIF.

           RA_KOSTL-SIGN = 'I'.

           RA_KOSTL-OPTION = 'EQ'.

           RA_KOSTL-LOW = WA_FINAL-KOSTL.

           RA_KOSTL-HIGH = ''.

           APPEND RA_KOSTL.

           RA_KSTAR-SIGN = 'I'.

           RA_KSTAR-OPTION = 'EQ'.

           RA_KSTAR-LOW = WA_FINAL-KSTAR.

           RA_KSTAR-HIGH = ''.

           APPEND RA_KSTAR.

           SUBMIT RKAEP000 WITH P_TCODE = 'KSB1'

                           WITH KOSTL   IN RA_KOSTL

                           WITH KSTAR   IN RA_KSTAR

                           WITH R_BUDAT IN RA_DATUM

                           WITH P_DISVAR = '1SAP'

                           EXPORTING LIST TO MEMORY AND RETURN.

           CALL FUNCTION 'LIST_FROM_MEMORY'  " Read list from memory into table

             TABLES

               listobject = LT_LISTOBJECT

             EXCEPTIONS

               not_found  = 1

               OTHERS     = 2.

           CALL FUNCTION 'LIST_TO_ASCI'      " Conversion of data to ASCII

             TABLES

               listobject         = LT_LISTOBJECT

               listasci           = TXTLINES

             EXCEPTIONS

               empty_list         = 1

               list_index_invalid = 2

               OTHERS             = 3.

           CALL FUNCTION 'LIST_FREE_MEMORY'  " Free memory

             TABLES

               listobject = LT_LISTOBJECT.

           DESCRIBE TABLE TXTLINES LINES VAR_LINE.

           VAR_LINE = VAR_LINE - 1.

           READ TABLE TXTLINES INTO WA_TXT INDEX VAR_LINE.

           SHIFT WA_TXT LEFT BY 35 PLACES.

           IF WA_TXT IS NOT INITIAL.

             SEARCH WA_TXT FOR '|'.

             CHAR_AMOUNT = WA_TXT+0(SY-FDPOS).

             CALL FUNCTION 'C14DG_CHAR_NUMBER_CONVERSION'

               EXPORTING

                 I_STRING                         = CHAR_AMOUNT

               IMPORTING

                 E_DEC                            = WA_FINAL-ACTUAL_01.

           ENDIF.

         WHEN '002'.

           CALL FUNCTION 'G_POSTING_DATE_OF_PERIOD_GET'

             EXPORTING

               PERIOD                    = '002'

               VARIANT                   = 'V3'

               YEAR                      = P_GJAHR

            IMPORTING

              FROM_DATE                  = RA_DATUM-LOW

*            LAST_NORMAL_PERIOD         =

              TO_DATE                    = RA_DATUM-HIGH

*            FROM_DATE_ORIG             =

                   .

               IF SY-SUBRC EQ 0.

                 RA_DATUM-SIGN = 'I'.

                 RA_DATUM-OPTION = 'EQ'.

                 APPEND RA_DATUM.

               ENDIF.

           RA_KOSTL-SIGN = 'I'.

           RA_KOSTL-OPTION = 'EQ'.

           RA_KOSTL-LOW = WA_FINAL-KOSTL.

           RA_KOSTL-HIGH = ''.

           APPEND RA_KOSTL.

           RA_KSTAR-SIGN = 'I'.

           RA_KSTAR-OPTION = 'EQ'.

           RA_KSTAR-LOW = WA_FINAL-KSTAR.

           RA_KSTAR-HIGH = ''.

           APPEND RA_KSTAR.

           SUBMIT RKAEP000 WITH P_TCODE = 'KSB1'

                           WITH KOSTL   IN RA_KOSTL

                           WITH KSTAR   IN RA_KSTAR

                           WITH R_BUDAT IN RA_DATUM

                           WITH P_DISVAR = '1SAP'

                           EXPORTING LIST TO MEMORY AND RETURN.

           CALL FUNCTION 'LIST_FROM_MEMORY'  " Read list from memory into table

             TABLES

               listobject = LT_LISTOBJECT

             EXCEPTIONS

               not_found  = 1

               OTHERS     = 2.

           CALL FUNCTION 'LIST_TO_ASCI'      " Conversion of data to ASCII

             TABLES

               listobject         = LT_LISTOBJECT

               listasci           = TXTLINES

             EXCEPTIONS

               empty_list         = 1

               list_index_invalid = 2

               OTHERS             = 3.

           CALL FUNCTION 'LIST_FREE_MEMORY'  " Free memory

             TABLES

               listobject = LT_LISTOBJECT.

           DESCRIBE TABLE TXTLINES LINES VAR_LINE.

           VAR_LINE = VAR_LINE - 1.

           READ TABLE TXTLINES INTO WA_TXT INDEX VAR_LINE.

           SHIFT WA_TXT LEFT BY 35 PLACES.

           IF WA_TXT IS NOT INITIAL.

             SEARCH WA_TXT FOR '|'.

             CHAR_AMOUNT = WA_TXT+0(SY-FDPOS).

             CALL FUNCTION 'C14DG_CHAR_NUMBER_CONVERSION'

               EXPORTING

                 I_STRING                         = CHAR_AMOUNT

               IMPORTING

                 E_DEC                            = WA_FINAL-ACTUAL_02.

           ENDIF.

6 REPLIES 6
Read only

Former Member
0 Likes
853

Hi,

Once you are doing Submit program go to that program by creating break point in debugging mode and check what is happenng ie r u getting the inputs in correct manner.

This will give you an idea about what is actually happening.Hope this will be helpful.

Read only

Former Member
0 Likes
853

Hi Sijin

are you using select options for 02 to 04 input.?

if ys then simply select data based on the select options field name  .

what exactly happens here is when user press submit ,sy-ucomm = "submit" and then it checks the

when condition and doesnot come back to case again.

regards

vaibhav

Read only

0 Likes
853

Very thanks to  both of you for your replies.

In select option when I am giving 02-03

The SUBMIT call is first made to CASE 02 which fetches results and after that when call is made to CASE 03 no data is fetched ( But data is there ).

Now when I am giving input 03-04

Then SUBMIT is returning data for CASE 03 but not for CASE 04 ( Even if there is data ).

Read only

0 Likes
853

Hi

i thnk that is because you are using '001' in period only.

like

CALL FUNCTION 'G_POSTING_DATE_OF_PERIOD_GET'

             EXPORTING

               PERIOD                    = '001' "***********this line ,  i think you should use here the name of the  select options (i am guessing this ,if this is the period                                                                           being taken entered by  user)

               VARIANT                   = 'V3'

               YEAR                      = P_GJAHR

            IMPORTING

              FROM_DATE                  = RA_DATUM-LOW

*            LAST_NORMAL_PERIOD         =

              TO_DATE                    = RA_DATUM-HIGH

*            FROM_DATE_ORIG             =

                   .

               IF SY-SUBRC EQ 0.

                 RA_DATUM-SIGN = 'I'.

                 RA_DATUM-OPTION = 'EQ'.

                 APPEND RA_DATUM.

               ENDIF.

regards

vaibhav

Read only

0 Likes
853

No man ,

That part is working  perfectly all right.

That code is for fetching starting  and ending date of a period based on Fiscal year , Fiscal year Variant and Period number.

So that I can input the same to KSB1 and get period wise data.

Read only

0 Likes
853

I guess the FM

CALL FUNCTION 'LIST_FREE_MEMORY

is causing the problem