Application Development 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: 

Call transaction Vl23 with variant and execute the background job in custom report.

former_member486356
Participant
0 Kudos

Hi folks,

I have one requirement in which I have to do mass PGI from the custom program by calling vl23 in background.

I have a below requirement:

Create a new variant in transaction VL23 for a background process. Call the variant and input the delivery order numbers from upload file. Execute the background job for PGI immediately.

Could anyone help on this to how we can proceed for this.

10 REPLIES 10

Rashid_Javed
Contributor
0 Kudos

Well I don’t have experience of using VL23, but I think we have couple of options.

1: Is it possible to record a BDC session of this transaction. If yes, then you can treat it as a batch input program. Create a recording (through transaction SHDB) and edit it as per your needs.

2: If above is not possible, please note that by looking at VL23 in SE93 reveals that it is using a program called RV50BTCH.

If you check this program in SE80, it has a standard variant “SAP&STANDARD”. This variant is in fact pointing to a report called “WS_MONITOR_OUTB_DEL_GDSI”.

Now this report “WS_MONITOR_OUTB_DEL_GDSI” is a standard report (type 1 executable). So you can call it using “Submit” statement in your code. If you check documentation for Submit command, you can pass data to selection screen variable and you can submit it as a background job. So hopefully by directly calling the report “WS_MONITOR_OUTB_DEL_GDSI” you can resolve this issue.

RJv

0 Kudos

Hi Rashid,

I think BDC will not be possible for this TCode as the 1st screen in creation of variant it may get some issue while posting one by one delivery by creating variant 1st.

For the second option I have to check whether this program directly do th PGI once click on submit or some other screen will also come as if executing the program if we get one more screen I don't think we can use Submit. Is my understanding is correct?

0 Kudos

Hi Alkma,

With reference to your comment, I think you have to try that. Since this program is supposed to run in background, so i am hoping there should not be any further screens/dialogs. In same cases the program do perform a check in code (like checking sy-batch) to verify if it is running in background or foreground mode and behave accordingly. I hope WS_MONITOR_OUTB_DEL_GDSI is one of thoise well behaved programs 🙂

Submit has many options available. You can submit a report as a background job. there is sample code for that in SAP documentation for submit.

RJv

0 Kudos

Hi Rashid,

I have checked this Program and yes it has another screen after entering the delivery number . I don't think submit will work in this case. Is it possible to use submit in this case as well?

0 Kudos

I think it should be able to run in background. Unfortunately in out landscape we do not use this functionality and when i try to execute the report i get no output whatsoever. However i noticed that on report selection screen there is a button called "Goods issue in background". what happens when you select it? Seems like it should work.

RJv

0 Kudos

Hi Rashid,

This button ask for output type 1st then the information regarding when you want to schedule job. Its again 1 and 2 screen after clicking this . So submit won't work I think here and In BDC for vl23 ,the recoeding is not capturing the 1st screen of variant. I think BAPI may work here but I checked some BAPI it also not giving proper result.No luck till now how I can acheive this.

Rashid_Javed
Contributor
0 Kudos

That screen is for output type/printer specifications and the next one is job schedule screen. Both will not appear while scheduling a job programatically. Check the following link for more information on how to program with ABAP background processing system.

Programming with the Background Processing System

And following code example is from ABAP documentation of Submit command. I hope you do have access to ABAP help in your system.

DATA: number           TYPE tbtcjob-jobcount, 

      name             TYPE tbtcjob-jobname VALUE 'JOB_TEST', 

      print_parameters TYPE pri_params. 

... 

CALL FUNCTION 
'JOB_OPEN' 
  EXPORTING 
    jobname              = name 
  IMPORTING 

    jobcount             = number 
  EXCEPTIONS 

    cant_create_job  = 1 
    invalid_job_data = 2 

    jobname_missing      = 3 
    OTHERS           = 4. 
IF sy-subrc = 
0. 
  SUBMIT submitable TO SAP-SPOOL 
                    SPOOL PARAMETERS 
print_parameters 
                    WITHOUT SPOOL DYNPRO 

                    VIA JOB name NUMBER number 
                    AND 
RETURN. 
  IF sy-subrc = 0. 
    CALL FUNCTION 'JOB_CLOSE' 

      EXPORTING 
        jobcount             = number 

        jobname              = name 
        strtimmed            = 'X' 

      EXCEPTIONS 
        cant_start_immediate = 1 

        invalid_startdate    = 2 
        jobname_missing      = 3 

        job_close_failed     = 4 
        job_nosteps          = 5 

        job_notex            = 6 
        lock_failed          = 7 

        OTHERS               = 8. 
    IF sy-subrc <> 0. 

      ... 
    ENDIF. 
  ENDIF. 
ENDIF. 
RJv

0 Kudos

Okay let me check this by creating a test program. But I have one doubt Submit will work as for execute button only and we are referring for good issue in background button. So if we submit the program how it handle that button.? Because on click of execute there are list is coming which we have to select so that can't be done through SUbmit.

Could you please explain me this. Then I can process check with test program.

I have also find one FM WS_DELIVERY_UPDATE for this but need to check.

0 Kudos

Before writing any program, just try to run that report by that button. You mentioned that it is showing you two screen, just don't worry about the screens now. These are just for defining printer and job attributes. Provide whatever data these are asking for. What is more important is that once the job is scheduled in background and complete; how does it behave? Does it perform the expected operation (Good issue ??) or does it end in some error (should check it through SM37)?

Only when you are sure that the report WS_MONITOR_OUTB_DEL_GDSI is working fine through background job (by use of that button), you should go ahead with program and use of Submit. Referring to your question,when you use Submit with argument "JOB name NUMBER number AND RETURN", you are submitting report to a background job (same as wheb you press that button on report selection screen ) Only difference is that you are doing it through program instead of frontend GUI.

RJv

0 Kudos

Hi Rashid ,

Yes that button in working fine as it is scheduling the PGI in background and showing which document is posted and which all are not .

I will try to implement the submit program logic in my custom report and come back to update was it working or not.

Thank you for you guidance will Update after the implementation.