Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all 943 articles
Browse latest View live

Suppressing Invoice List Creation via VF01/VF04

$
0
0

Hello Guys,

 

I am writing this blog as a guide for those who will have the same requirement.

It might not solve your queries directly but I believe it will still throw some light if kind of relevant to my requirement.

 

 

Overview of Requirement:

 

Recently I got an enhancement to suppress the invoice list creation during invoice creation in VF01/VF04

Creation of invoice list will be controlled by checking "if the invoice to be created" in VF01/VF04 has a combination stored in our custom table.

 

So...If the combination is maintained (RELEVANT for invoice list creation)

then do not change anything

 

If the combination is NOT maintained (NOT RELEVANT for invoice list creation)

then I need to:

 

1. Clear the Invoice list details in the Header Details section of VF01/VF04.

2. No invoice creation will happen/ no results in VF24 upon successful invoice creation in VF01/VF04.

3. Clear 1 field in VBUK-RELIK (relevancy for invoice list)

4. Clear 2 fields in VBRK-FKART_RL (invoice list type) & VBRK-FKDAT_RL invoice list billing date

 

 

 

Disclaimer:

I do have a limited understanding of the whole detailed SD flow but what I know is:

 

1. Once we create an invoice in VF01/VF04 -> it will create an invoice list by SAP standard process if the document is properly configured which we can see in   VF24. (see below)

Invoice List vf24.PNG

 

2. Should the invoice is not created after running VF01/VF04 -> then there could be a set up to make it invoice list creation relevant (I tapped my SD functional for this configurations and he did it for me)

 

3.  I am also checking the header part in VF01/VF04 (before creating of invoice list) if it is relevant for invoice creation if there is Invoice List Type and billing date on the header part. If the Invoice List is not relevant for creation then we should make both fields blank.

VF01 - setp 1.PNG

 

VF01 - setp 2.PNG

 

 

 

 

Solution:


1. & 4 Clearing Invoice list Type and Billing date in Header part can be done on Include MV60AF0V_VBRK_BEARBEITEN.

In this include, the header details are still being initialized.

 

I put an implicit enhancement to clear both fields in table VBRK and in XVBRK - see below

INCL_MV60AF0V_VBRK_BEARBEITEN.PNG

Once the invoice list is NOT RELEVANT, (see below) --> If we Press on header details icon or go to Header - header, both Invoice list type and billing date is blank.

Invoice List Creation - relevancy2.PNG

 

# 4 issue - will also be solved as once we clear both VBRK fields (Invoice List type and billing date from this point, once we press save, it will not create any data in VBRK upon invoice posting later on)


Now done with issue number #1 & #4.
moving forward with # 2 & 3.

 

 

2. & 3.  VBUK data is not yet present in the above include so we need to find another spot to initialize VBUK data (relik) and the invoice list creation suppression (for it not to show in VF24).

 

Once we hit on save - there is a FM being called - named "RV_INVOICE_DOCUMENT_ADD which will add the invoice data to the data base tables.

 

 

RV_INVOICE_DOCUMENT_ADD.PNG

I placed my logic inside this subroutine - see below:

In line 234 you can see that I cleared VBUK data

RV60AFZZ - USEREXIT.PNG

Being VBUK-RELIK (Invoice List creation Relevance Indicator) blank - this means that it will no longer be relevant for invoice list creation.

This will solve # 2 & # 3.

 

 

Kr,

Maki


'Column view' in SAPScripts/ Smartforms

$
0
0

As developers, many of us would have faced this challenge atleast once - the 'Terms and Conditions' Page. Most customers have T&C pages looking like this - with column view.

2016-07-12 11_11_05-terms-conditions.png (1475×1809).jpg

 

This is easily achievable in MS Word, using the option under Page Layout.

2016-07-12 11_15_41-Document1 - Microsoft Word.jpg

 

How do you achieve this in SAP? Traditional wisdom may tell you to keep 2 text boxes - on left & right and 2 text objects to include in them. But, what if the text content changes or the font changes? When using 2 text boxes, the text from 1st box doesn't overflow to the 2nd box automatically.

 

Some other posts on SCN tells to scan the entire T&C Page as an image and include that as a graphic on the form. But, wouldn't that require a transport whenever the text content needed to be changed (Agreed that T&C doesn't change very often)? Also, including a high clarity image on the file means, increasing the file size.

 

Solution -Play with the generated OTF. OTF data is a series of commands and contents. If you know how to play around with the commands, you can insert/delete/modify the structure of the output, different from the way it was originally designed in the Smartform/ SAPScript.


Here, I am taking an example of 2 column view. You may extend concept this to any number of columns.


Goto SO10, create the text, containing T&C details - or as an example upload any dummy text file.

2016-07-12 11_29_15-Change Standard text_ Z1 Language EN.jpg


Create a Smartform with 2 pages, both containing MAIN windows, at required column positions. Page1 should have Page2 as the next page and Page2 should have Page1 as the next page.


My Page1:

2016-07-12 11_31_48-SAP Form Builder_ Change Page PAGE1.jpg

 

My Page 2:

2016-07-12 11_31_58-SAP Form Builder_ Change Page PAGE2.jpg

 

Now, include the text object in the MAIN window.

2016-07-12 11_33_13-SAP Form Builder_ Change Text TEXT1.jpg

 

Create a driver program to call the Smartform and get back OTF data.

 

Without any modifications to the OTF structure, the output looks like this:

Page 1:

2016-07-12 11_36_33-merg.pdf - Adobe Reader.jpg

Page 2:

2016-07-12 11_36_47-merg.pdf - Adobe Reader.jpg

Just like the way it was designed in the Smartform.

 

Now, OTF analysis:

 

Everytime a new page begins, OTF uses command OP and everytime a page ends, OTF uses command EP (Full list of OTF commands are listed in program RSTXDATAOTF). If you delete OP and EP commands from OTF data, system wouldn't know to split the page/ start a new page. This is the technique I am going to use here. Lets debug:

 

Here is my OTF data:

2016-07-12 11_43_11-ABAP Debugger.jpg

I have circled here the first OP command, which tells the system to begin the 1st page. Lets find the next page - that is by finding the next OP command.

2016-07-12 11_43_35-.jpg

Here is the next OP command. Here, you will see that 1st page is closed with EP command and the next page is started with OP command.

2016-07-12 11_43_47-ABAP Debugger.jpg

Lets delete these entries and see what happens.

2016-07-12 11_44_25-ABAP Debugger.jpg

Now, SAP wouldn't know to start the next page and will think that the contents of the 2nd page in the Smartform is actually part of the 1st page in the output.

 

Have a look at this output. You will see that the contents from both pages have merged together to form a single page.

2016-07-12 11_44_54-merg.pdf - Adobe Reader.jpg

 

With this method, even if text or font changes in the included text, the contents adjust automatically. Please take note that common portions of page - like heading, logo, address, other texts etc, need to be defined only on Page1. If you need more columns in the output, you will need to have more intermediate pages in the Smartform.


Eg. to build a 3 column view:

Page1 (with logo, address, other constant texts, main window equivalent to the size of 1st column), having Next page as Page2

Page2 (main window equivalent to the size of 2nd column), having Next page as Page3

Page3 (main window equivalent to the size of 3nd column), having Next page as Page1

And, build a looping logic to delete OP commands for Pages 2 & 3 (so that 2nd & 3rd pages doesn't start), and EP commands for Pages 1 & 2 (so that 1st & 2nd pages doesn't close).


Once you have the manipulated OTF, use function modules CONVERT_OTF_2_PDF to convert it to PDF or PRINT_OTF to send it to printer spool.


Please let me know if any portion of this document is not clear, so that I may improve the relevant portions.

 

Thanks for reading,

Juwin

Monitoring the SCC4 transaction

$
0
0

Hi,

I found it interesting to share this code because it serves to monitor the SCC4 , it is a transaction that opens the SAP environment to change ... where they can be made ​​without request.

This can cause several problems with audit inconsistency environments ... We will have a table that stores user data and email that will receive the notification.

After a job is triggered to run Z program at this point if the environment is open, it will trigger an email displaying the environment and principal for people registered in the table.


Steps:

1 - Create Table

Table: ZBASIS_DEST_MAIL

 

MANDMANDTCLNT30Client
USUARIOXUBNAMECHAR120User Name in User Master Record
EMAILAD_SMTPADRCHAR2410E-Mail Address


2 - Create program
ABAP:


*&---------------------------------------------------------------------*
*& Report  ZJOB_STATUS_SCC4
*&
*&---------------------------------------------------------------------*
*& mail: tobias@tolfo.com.br
*&phone: +55 5599510981
*&---------------------------------------------------------------------*
REPORT  ZJOB_STATUS_SCC4.
TABLES: T000.
TYPES: BEGIN OF ty_tbtco,            jobname   TYPE tbtco-jobname,            sdlstrtdt TYPE tbtco-sdlstrtdt,            sdlstrttm TYPE tbtco-sdlstrttm,       END OF ty_tbtco.
TYPES: BEGIN OF ty_tbtcom,            sdlstrtdt TYPE tbtco-sdlstrtdt,            sdlstrttm TYPE tbtco-sdlstrttm,       END OF ty_tbtcom.
DATA: it_t000      TYPE TABLE OF t000,      gt_tbtco     TYPE TABLE OF ty_tbtco,      gt_dest_mail TYPE TABLE OF zbasis_dest_mail.
DATA: wa_dest_mail  TYPE  zbasis_dest_mail,      wa_t000       TYPE t000,      wa_tbtco      TYPE ty_tbtco.
*validacao dos parametros
PERFORM parameters_t000.
*&---------------------------------------------------------------------*
*&      Form  parameters
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM parameters_t000 .
* Ini.1- Seleciona os mandantes que estao abertos
 SELECT *   FROM t000   INTO TABLE it_t000   WHERE CCCORACTIV <> '2' OR CCNOCLIIND <> '3'.
* End.1
* Ini.2 - Verifica se existe algum ambiente aberto, se verdadeiro ele vai selecionar
* os emails que devem receber a notificacao, caso contrario nao executa o programa.    IF it_t000 IS NOT INITIAL.        PERFORM select_mail.    ELSE.         EXIT.    ENDIF.
* End.2
ENDFORM.                    " parameters_t000
*&---------------------------------------------------------------------*
*&      Form  SELECIONA_EMAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM select_mail .
* Ini. 3 - Seleciona os emails
 SELECT *  FROM ZBASIS_DEST_MAIL  INTO TABLE gt_dest_mail.
* End. 3
* Ini 4. Verifica se existe algum email cadastrado para enviar a notificacao.
* e realiza a chamada.  IF gt_dest_mail[] IS INITIAL.    MESSAGE text-003 TYPE 'S'.    STOP.  ENDIF.  PERFORM send_mail.
ENDFORM.                    " select_mail
*&---------------------------------------------------------------------*
*&      Form  send_mail
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM send_mail .  DATA: lt_receivers TYPE TABLE OF somlreci1,        lt_txt       TYPE TABLE OF solisti1.  DATA: wa_doc_data  TYPE sodocchgi1,        wa_receivers TYPE somlreci1,        wa_txt       TYPE solisti1.  REFRESH: lt_receivers, lt_txt.  CLEAR:   wa_receivers, wa_txt, wa_doc_data.  LOOP AT gt_dest_mail INTO wa_dest_mail.          wa_receivers-receiver = wa_dest_mail-email.          wa_receivers-rec_type = 'U'.       APPEND wa_receivers TO lt_receivers.       CLEAR wa_receivers.  ENDLOOP.
* Ini.5 - Montanto as mensagens  wa_doc_data-obj_descr = 'Status do Ambientes atraves da  SCC4 -  ' && sy-host && sy-mandt.  wa_txt-line =           'Ambientes Alterados: ' .  APPEND wa_txt TO lt_txt.  LOOP AT it_t000 INTO wa_t000.    wa_txt-line(32) = wa_t000-mtext.    WRITE wa_t000-mandt        TO wa_txt-line+35(12).    WRITE wa_t000-changeuser   TO wa_txt-line+50(11).    WRITE wa_t000-changedate   TO wa_txt-line+70(13).    APPEND wa_txt TO lt_txt.
* End.5  ENDLOOP.
* Chama funcao para o envio do email  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'    EXPORTING      document_data              = wa_doc_data      document_type              = 'RAW'      put_in_outbox              = 'X'      commit_work                = 'X'    TABLES      object_content             = lt_txt      receivers                  = lt_receivers    EXCEPTIONS      too_many_receivers         = 1      document_not_sent          = 2      document_type_not_exist    = 3      operation_no_authorization = 4      parameter_error            = 5      x_error                    = 6      enqueue_error              = 7      OTHERS                     = 8.
 ENDFORM.                    " send_mail

 

2 - Create JOB
The job time is the User discretion, in my case I use 1 minute.

 

 

3 - Email layout received

 

sap.PNG

Any doubts I am available,

Tobias Tolfo



Viewing all 943 articles
Browse latest View live