Wednesday, September 25, 2013

SAP ABAP ADOBE FORMS Long Texts

I have received an issue that will pass a table via interface into Adobe Forms.

One of the fields in the table has a 500 char data element.

The issue is when I tried to display the table in adobe forms, the field that will contain the 500 char does not display its full content. The content will be truncated.

I managed to find a solution: http://forums.adobe.com/thread/450522

It states that the following needs to be done:
1. The TextField object should be contained in a subform that is set to Content: Flowed.  This isn't technically necessary, but if you have anything below the expanding text box and the subform is set to Positioned, the text will expand and overlay what's below.
2. On the Field tab of the text field's Object property tab, check the Allow Multiple Lines checkbox
3. On the Layout tab, check the Expand To Fit checkbox under Y:/Height




And then the output can finally be displayed, in its column.


Wednesday, December 5, 2012

Webdynpro - validation



The following is a validation, using method check_mandatory_attr_on_view.

The common validation message is 'please fill in required field'.

However, if there are 5 mandatory fields, the same message comes out 5 times.

The code below has changed that, which has a customized message for each mandatory field.

It utilizes the both the 'report_attribute_t100_message' and check_mandatory_attr_on_view method.

An error message will come at the top of the screen, with the mandatory input fields highlighted in red.



method CHECK_REQUIRED .

* Data declaration
   DATA:
   lo_view_controller TYPE REF TO if_wd_view_controller,
   lo_dyn TYPE REF TO cl_wd_dynamic_tool.

* Create Object
  CREATE OBJECT lo_dyn.
  DATA lt_messages TYPE lo_dyn->t_check_result_message_tab.
  DATA ls_messages TYPE lo_dyn->t_check_result_message.

* Get view controller reference
  lo_view_controller = wd_this->wd_get_api( ).

  CALL METHOD cl_wd_dynamic_tool=>check_mandatory_attr_on_view
    EXPORTING
      view_controller  = lo_view_controller
      display_messages = abap_false
    IMPORTING
      messages         = lt_messages.

*-------------------------------------------------------------
  DATA: lo_node TYPE REF TO if_wd_context_node.
  DATA: lo_node_info TYPE REF TO if_wd_context_node_info.
  DATA: lw_attr_info TYPE wdr_context_attribute_info.
  DATA: lw_x030l TYPE x030l.
  DATA: l_reptext TYPE reptext.
  DATA: l_msg TYPE string.
  DATA: l_msgv1 TYPE symsgv.

  DATA: lt_msg TYPE cl_wd_dynamic_tool=>t_check_result_message_tab.

  FIELD-SYMBOLS: LIKE LINE OF lt_msg.

  DATA:  lo_componentcontroller TYPE REF TO ig_componentcontroller
        , lo_current_controller TYPE REF TO if_wd_controller
        , lo_view_controllerz TYPE REF TO if_wd_view_controller
        , lo_message_manager TYPE REF TO if_wd_message_manager
        .

  lo_current_controller ?= wd_this->wd_get_api( ).
  lo_message_manager = lo_current_controller->get_message_manager( ).
  lo_view_controllerz = wd_this->wd_get_api( ).

  wd_assist->CHG_MANDATORY_MSG( exporting it_msg          = lt_messages
                                          io_msg_manager  = lo_message_manager
                                          i_msgid         = 'ZNAN_VISIBLE'
                                          i_msgno         = '001' ).

endmethod.

method CHG_MANDATORY_MSG.
* The following are the parameters
* IT_MSG TYPE CL_WD_DYNAMIC_TOOL=>T_CHECK_RESULT_MESSAGE_TAB.
* IO_MSG_MANAGER TYPE REF TO IF_WD_MESSAGE_MANAGER.
* I_MSGID TYPE SYMSGID
* I_MSGNO TYPE SYMSGNO

method CHG_MANDATORY_MSG.

  DATA: lo_node         TYPE REF TO if_wd_context_node.
  DATA: lo_node_info    TYPE REF TO if_wd_context_node_info.
  DATA: lw_attr_info    TYPE wdr_context_attribute_info.
  DATA: lw_x030l        TYPE x030l.
  DATA: l_reptext       TYPE reptext.
  DATA: l_msg           TYPE string.
  DATA: l_msgv1         TYPE symsgv.
  DATA: l_message       TYPE t_check_result_message.
  FIELD-SYMBOLS: LIKE LINE OF it_msg.

  LOOP AT it_msg ASSIGNING .
    CALL METHOD -context_element->get_node
      RECEIVING
        node = lo_node.

    CALL METHOD lo_node->get_node_info
      RECEIVING
        node_info = lo_node_info.

    CALL METHOD lo_node_info->get_attribute
      EXPORTING
        name           = -attribute_name
      RECEIVING
        attribute_info = lw_attr_info.


    CALL METHOD lw_attr_info-rtti->get_ddic_header
      RECEIVING
        p_header = lw_x030l.


    SELECT SINGLE scrtext_l FROM dd04t
      INTO l_msgv1 WHERE
       rollname = lw_x030l-tabname AND
      ddlanguage = sy-langu AND
      as4local =  'A'.

    MESSAGE
      ID
        i_msgid
      TYPE
        -t100_message-msgty
      NUMBER
      i_msgno
      WITH
       l_msgv1
    INTO l_msg.

        CLEAR: l_message.
        l_message-context_element = -context_element.
        l_message-attribute_name = -attribute_name.
        l_message-t100_message-msgty = 'E'.
        l_message-t100_message-msgid = i_msgid.
        l_message-t100_message-msgno = i_msgno.
        l_message-t100_message-MSGV1 = l_msgv1.

    CALL METHOD io_msg_manager->report_attribute_t100_message(
            EXPORTING
              msg                       =   l_message-t100_message
              element                   =   -context_element
              attribute_name            =   -attribute_name ).

*    CALL METHOD io_msg_manager->report_error_message
*      EXPORTING
*        message_text = l_msg
*        ENABLE_MESSAGE_NAVIGATION = abap_true.


  ENDLOOP.


endmethod.

Friday, August 24, 2012

SD - Billing: automatic email when create invoice: VF01

setting to be done:

1.settings with tcode:
vv32.
nace --> v3-billing--> put your form name, driver program and routine.

2. write routine in driver program to email.

vv32 settings:

for email, set medium to 5-external send and date/time to 4 - immediately.




nace settings:
select you application. IN this case, its V3 - billing, then click output types.

highlight outputtype (ZD00) and click on processing routines


Fill in required details.


Create routines in dirver program:
example:

REPORT zsd_rlb_invoice_zd00.

* declaration of data
INCLUDE rlb_invoice_data_declare.
* definition of forms
INCLUDE rlb_invoice_form01.
INCLUDE rlb_print_forms.
INCLUDE zrlb_top.                                           " crq6257
DATA: gw_title TYPE string,
      gw_date  TYPE string.

*---------------------------------------------------------------------*
*       FORM ENTRY
*---------------------------------------------------------------------*
FORM entry USING return_code us_screen.

  DATA: lf_retcode TYPE sy-subrc.
  CLEAR retcode.
  xscreen = us_screen.
  PERFORM processing USING us_screen
                     CHANGING lf_retcode.
  IF lf_retcode NE 0.
    return_code = 1.
  ELSE.
    return_code = 0.
  ENDIF.

ENDFORM.                    "ENTRY
*---------------------------------------------------------------------*
*       FORM PROCESSING                                               *
*---------------------------------------------------------------------*
FORM processing USING proc_screen
                CHANGING cf_retcode.

  DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.
  DATA: ls_bil_invoice        TYPE lbbil_invoice.
  DATA: lf_fm_name            TYPE rs38l_fnam.
  DATA: ls_control_param      TYPE ssfctrlop.
  DATA: ls_composer_param     TYPE ssfcompop.
  DATA: ls_recipient          TYPE swotobjid.
  DATA: ls_sender             TYPE swotobjid.
  DATA: lf_formname           TYPE tdsfname.
  DATA: ls_addr_key           LIKE addr_key.
  DATA: ls_dlv-land           LIKE vbrk-land1.
  DATA: ls_job_info           TYPE ssfcrescl.
  DATA: ls_totqty             TYPE i.                       "SR304987
  DATA: l_fkart2              TYPE c.                       "SR304987

* SmartForm from customizing table TNAPR
  lf_formname = tnapr-sform.

* determine print data
  PERFORM set_print_data_to_read USING    lf_formname
                                 CHANGING ls_print_data_to_read
                                 cf_retcode.

  IF cf_retcode = 0.
* select print data
    PERFORM get_data USING    ls_print_data_to_read
                     CHANGING ls_addr_key
                              ls_dlv-land
                              ls_bil_invoice
                              cf_retcode.
  ENDIF.

  IF cf_retcode = 0.
    PERFORM set_print_param USING    ls_addr_key
                                     ls_dlv-land
                            CHANGING ls_control_param
                                     ls_composer_param
                                     ls_recipient
                                     ls_sender
                                     cf_retcode.
  ENDIF.

  IF cf_retcode = 0.
* determine smartform function module for invoice
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING  formname           = lf_formname
*                 variant            = ' '
*                 direct_call        = ' '
         IMPORTING  fm_name            = lf_fm_name
         EXCEPTIONS no_form            = 1
                    no_function_module = 2
                    OTHERS             = 3.
    IF sy-subrc <> 0.
*   error handling
      cf_retcode = sy-subrc.
      PERFORM protocol_update.
    ENDIF.
  ENDIF.

  PERFORM reverse_by_bill_type CHANGING ls_bil_invoice.     "26.06.09

  PERFORM f_checkqty USING    ls_bil_invoice                "SR304987
                     CHANGING ls_totqty                     "SR304987
                              l_fkart2.                     "SR304987

  IF ls_totqty > 0.                                         "SR304987
    IF cf_retcode = 0.
      PERFORM check_repeat.                                 "SR304987
*      PERFORM zcheck_repeat.                                "SR304987
      IF ls_composer_param-tdcopies EQ 0.
        nast_anzal = 1.
      ELSE.
        nast_anzal = ls_composer_param-tdcopies.
      ENDIF.
      ls_composer_param-tdcopies = 1.
*      DO nast_anzal TIMES.
* In case of repetition only one time archiving
      IF sy-index > 1 AND nast-tdarmod = 3.
        nast_tdarmod = nast-tdarmod.
        nast-tdarmod = 1.
        ls_composer_param-tdarmod = 1.
      ENDIF.
      IF sy-index NE 1 AND repeat IS INITIAL.
        repeat = 'X'.
      ENDIF.

      ls_composer_param-tdnewid     = 'X'.
      ls_composer_param-tdtelenum   = ls_bil_invoice-hd_gen-bil_number.
      ls_composer_param-tdtelenume  = ls_bil_invoice-hd_gen-sold_to_party.
      ls_composer_param-tddivision  = 'X'.

* crq6257
* The following validation is for bil type ZEUR, etc, etc.
      IF nast-nacha EQ '5' AND
          ( ls_bil_invoice-hd_gen-bil_type = 'ZEUR' OR
           ls_bil_invoice-hd_gen-bil_type = 'ZCWR' OR
           ls_bil_invoice-hd_gen-bil_type = 'ZEWR' OR
           ls_bil_invoice-hd_gen-bil_type = 'ZCN1' OR
           ls_bil_invoice-hd_gen-bil_type = 'ZCN2').


*Calling the SMARTFORM using the function module retrieved above
*GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
*format of the output
        CLEAR: ls_control_param-device.
        ls_control_param-no_dialog = 'X'.
        ls_control_param-preview = space. "Suppressing the dialog box for print preview
        ls_control_param-getotf = 'X'.

* call smartform invoice
        CALL FUNCTION lf_fm_name
          EXPORTING
            archive_index        = toa_dara
            archive_parameters   = arc_params
            control_parameters   = ls_control_param
            output_options       = ls_composer_param
            user_settings        = space
            is_bil_invoice       = ls_bil_invoice
            is_nast              = nast
            is_repeat            = repeat
            lt_title             = gw_title
            lt_date_type         = gw_date
          IMPORTING
            job_output_info    = ls_job_info
          EXCEPTIONS
            formatting_error     = 1
            internal_error       = 2
            send_error           = 3
            user_canceled        = 4
            OTHERS               = 5.

        IF sy-subrc <> 0.
*   error handling
          cf_retcode = sy-subrc.
          PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
          PERFORM add_smfrm_prot.
        ENDIF.

        lt_job_info       = ls_job_info.
        lt_bil_invoice    = ls_bil_invoice .
        lt_composer_param = ls_composer_param.

        PERFORM f_get_recipients.
        PERFORM f_convert_pdf.
        PERFORM f_email_body.
        PERFORM f_packing_list.
        PERFORM f_send_email.

      ELSE.

* call smartform invoice
        CALL FUNCTION lf_fm_name
             EXPORTING
                        archive_index        = toa_dara
                        archive_parameters   = arc_params
                        control_parameters   = ls_control_param
*                 mail_appl_obj        =
                        mail_recipient       = ls_recipient
                        mail_sender          = ls_sender
                        output_options       = ls_composer_param
                        user_settings        = space
                        is_bil_invoice       = ls_bil_invoice
                        is_nast              = nast
                        is_repeat            = repeat
                        lt_title             = gw_title
                        lt_date_type         = gw_date
             IMPORTING  job_output_info      = ls_job_info
*                     document_output_info =
*                     job_output_options   =
             EXCEPTIONS formatting_error     = 1
                        internal_error       = 2
                        send_error           = 3
                        user_canceled        = 4
                        OTHERS               = 5.
        IF sy-subrc <> 0.
*   error handling
          cf_retcode = sy-subrc.
          PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
          PERFORM add_smfrm_prot.
        ENDIF.
*      ENDDO.
      ENDIF.


* get SmartForm spoolid and store it in the NAST protocoll
      DATA ls_spoolid LIKE LINE OF ls_job_info-spoolids.
      LOOP AT ls_job_info-spoolids INTO ls_spoolid.
        IF ls_spoolid NE space.
          PERFORM protocol_update_spool USING '342' ls_spoolid
                                              space space space.
        ENDIF.
      ENDLOOP.
      ls_composer_param-tdcopies = nast_anzal.
      IF NOT nast_tdarmod IS INITIAL.
        nast-tdarmod = nast_tdarmod.
        CLEAR nast_tdarmod.
      ENDIF.

    ENDIF.
  ELSE.                                                     "SR304987
    IF sy-batch NE 'X'.                                     "SR304987
      MESSAGE s899(bd) WITH 'Invoice has a 0 quantity & cannot be printed'"SR304987
      EXIT.
    ELSE.
      WRITE 'batch'.
    ENDIF.                                                  "SR304987
  ENDIF.                                                    "SR304987
* get SmartForm protocoll and store it in the NAST protocoll
* PERFORM ADD_SMFRM_PROT.

ENDFORM.                    "PROCESSING

*start of insertion SR304987
*&---------------------------------------------------------------------*
*&      Form  F_CHECKQTY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_checkqty USING ls_bil_invoice TYPE lbbil_invoice
                CHANGING ls_totqty TYPE i
                         l_fkart2  TYPE c.

  TYPESBEGIN OF gty_it_gen.
          INCLUDE STRUCTURE lbbil_it_gen.
  TYPESEND OF gty_it_gen.

  RANGES: r_fkart FOR vbrk-fkart.

  DATA: gs_it_gen    TYPE gty_it_gen,
        l_fkart      LIKE vbrk-fkart
        .

*Assign range with document type
  r_fkart-low = 'F1'.
  r_fkart-option = 'EQ'.
  r_fkart-sign = 'I'.
  APPEND r_fkart.

  r_fkart-low = 'F2'.
  r_fkart-option = 'EQ'.
  r_fkart-sign = 'I'.
  APPEND r_fkart.

  r_fkart-low = 'ZDIS'.
  r_fkart-option = 'EQ'.
  r_fkart-sign = 'I'.
  APPEND r_fkart.

  r_fkart-low = 'ZEUR'.
  r_fkart-option = 'EQ'.
  r_fkart-sign = 'I'.
  APPEND r_fkart.

  r_fkart-low = 'ZTRS'.
  r_fkart-option = 'EQ'.
  r_fkart-sign = 'I'.
  APPEND r_fkart.

  CLEAR l_fkart2.
  CLEAR ls_totqty.

  READ TABLE ls_bil_invoice-it_gen INTO gs_it_gen INDEX 1.
  IF sy-subrc = 0.

    SELECT SINGLE fkart INTO l_fkart FROM vbrk
    WHERE vbeln = gs_it_gen-bil_number AND
          fkart IN r_fkart.
    IF sy-subrc = 0.
      l_fkart2 = 'X'.
    ENDIF.

    IF l_fkart2 EQ 'X'.
      SELECT SUM( fkimg ) FROM vbrp INTO ls_totqty
      WHERE vbeln = gs_it_gen-bil_number.
    ELSE.
      ls_totqty = '1'.
    ENDIF.

  ENDIF.

ENDFORM.                    " F_CHECKQTY
*End of insertion SR304987

*&---------------------------------------------------------------------*
*&      Form  ZCHECK_REPEAT
*&---------------------------------------------------------------------*
FORM zcheck_repeat .

  TYPESBEGIN OF ty_nast.
          INCLUDE STRUCTURE nast.
  TYPESEND OF ty_nast.

  DATA: t_nast TYPE TABLE OF ty_nast WITH HEADER LINE.

  CLEAR repeat.
  CLEAR t_nast.
  REFRESH t_nast.

*  SELECT * INTO *NAST FROM NAST WHERE KAPPL = NAST-KAPPL
*  WHERE KAPPL = NAST-KAPPL
*  AND   OBJKY = NAST-OBJKY
*  AND   KSCHL = NAST-KSCHL
*  AND   SPRAS = NAST-SPRAS
*  AND   PARNR = NAST-PARNR
*  AND   PARVW = NAST-PARVW
*  AND   NACHA BETWEEN '1' AND '4'.

  SELECT objky kschl spras parnr parvw vstat FROM nast
  INTO CORRESPONDING FIELDS OF TABLE t_nast
  WHERE kappl = nast-kappl
  AND   objky = nast-objky
  AND   kschl = nast-kschl
  AND   spras = nast-spras
  AND   parnr = nast-parnr
  AND   parvw = nast-parvw
  AND   nacha BETWEEN '1' AND '4'.

  DELETE ADJACENT DUPLICATES FROM t_nast.

  LOOP AT t_nast WHERE vstat = '1'.
    repeat = 'X'.
  ENDLOOP.

*    IF *NAST-VSTAT = '1'.
*      REPEAT = 'X'.
*    ENDIF.
*  ENDSELECT.


ENDFORM.                    " CHECK_REPEAT

*&---------------------------------------------------------------------*
*&      Form  REVERSE_BY_BILL_TYPE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM reverse_by_bill_type  CHANGING ps_bil_invoice TYPE lbbil_invoice.

  FIELD-SYMBOLS:
     TYPE lbbil_it_price,
      TYPE lbbil_hd_kond.

  CASE ps_bil_invoice-hd_gen-bil_type.
    WHEN 'ZLEP' OR  'ZLEF' OR 'ZFRA' OR 'ZFRH'.
      IF ps_bil_invoice-hd_gen-bil_netwr < 0.
        ps_bil_invoice-hd_gen-bil_netwr = ps_bil_invoice-hd_gen-bil_netwr * -1.
        ps_bil_invoice-hd_gen-bil_disc = ps_bil_invoice-hd_gen-bil_disc * -1.
        ps_bil_invoice-hd_gen-bil_tax = ps_bil_invoice-hd_gen-bil_tax * -1.
        ps_bil_invoice-hd_gen-dpnet = ps_bil_invoice-hd_gen-dpnet * -1.
        ps_bil_invoice-hd_gen-dpend = ps_bil_invoice-hd_gen-dpend * -1.
        ps_bil_invoice-hd_gen-dpmws_end = ps_bil_invoice-hd_gen-dpmws_end * -1.
        ps_bil_invoice-hd_gen-dpmws = ps_bil_invoice-hd_gen-dpmws * -1.
        LOOP AT ps_bil_invoice-it_price ASSIGNING .
          -netwr = -netwr * -1.
          -mwsbp = -mwsbp * -1.
          -netpr = -netpr * -1.
        ENDLOOP.

        LOOP AT ps_bil_invoice-hd_kond ASSIGNING .
          -kwert = -kwert * -1.
          -kawrt = -kawrt * -1.
        ENDLOOP.

        gw_date = 'Invoice Date (Tax Point)'.

        IF ps_bil_invoice-hd_gen-bil_type = 'ZLEP' OR ps_bil_invoice-hd_gen-bil_type = 'ZLEF'.
          SELECT  SINGLE vtext
              FROM  tvfkt
              INTO  gw_title
              WHERE spras EQ sy-langu
              AND   fkart EQ ps_bil_invoice-hd_gen-bil_type.
        ELSE.
          gw_title = 'Framework Invoice'.
        ENDIF.

      ELSE.
        IF ps_bil_invoice-hd_gen-bil_type = 'ZLEP' OR ps_bil_invoice-hd_gen-bil_type = 'ZLEF'.
          gw_title = 'Levy Credit'.
        ELSE.
          gw_title = 'Framework Credit'.
        ENDIF.

        gw_date = 'Credit Note Date (Tax Point)'.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.
ENDFORM.                    " REVERSE_BY_BILL_TYPE
*&---------------------------------------------------------------------*
*&      Form  F_SEND_EMAIL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_send_email .

  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      document_data                    = wa_document_data
     put_in_outbox                    = 'X'
     sender_address                   = gv_sender
     sender_address_type              = 'SMTP'
*     commit_work                      = '' "commit work will be done by ME29N
   IMPORTING
     sent_to_all                      = wa_sent_to_all
    TABLES
      packing_list                     = it_packing_list
     contents_bin                     = it_pdf
     contents_txt                     = it_body_msg
      receivers                        = it_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
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

** Equivalent for the Scot transaction, that is not automatic
*SUBMIT rsconn01 AND RETURN.


*  IF sy-sysid = 'ECD'.
*    WAIT UP TO 5 SECONDS.
*    SUBMIT rsconn01
*      WITH mode = 'INT'
*      WITH output = ''
*      AND RETURN.
*  ENDIF.

  CLEAR: gv_bin_filesize,
*          gv_attachment_name,
         wa_document_data,
         wa_receivers,
         wa_packing_list,
         wa_body_msg,
         wa_otf_data,
         wa_pdf.

  REFRESH: it_packing_list,
           it_pdf,
           it_body_msg,
           it_receivers,
           it_pdfdata,
           it_otf_final.


ENDFORM.                    " F_SEND_EMAIL
*&---------------------------------------------------------------------*
*&      Form  F_GET_RECIPIENTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_get_recipients.

  DATA: lv_adrnr TYPE kna1-adrnr,
        lv_stp   TYPE lbbil_invoice-hd_gen-sold_to_party.


  lv_stp = lt_bil_invoice-hd_gen-sold_to_party.

  SELECT SINGLE adrnr INTO lv_adrnr
     FROM kna1
    WHERE kunnr = lv_stp.

  IF sy-subrc EQ 0.

    SELECT SINGLE smtp_addr INTO gv_recepient
      FROM adr6
      WHERE addrnumber = lv_adrnr.

  ENDIF.

  wa_receivers-receiver = gv_recepient.
  wa_receivers-express = 'X'.
  wa_receivers-com_type = 'INT'.
  wa_receivers-rec_type = 'U'"Internet address
  wa_receivers-notif_del = 'X'" request delivery notification
  wa_receivers-notif_ndel = 'X'" request not delivered notification
  APPEND wa_receivers TO it_receivers.
  CLEAR: wa_receivers.



ENDFORM.                    " F_GET_RECIPIENTS
*&---------------------------------------------------------------------*
*&      Form  F_CONVERT_PDF
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_convert_pdf .


* APPENDING THE OTF DATA INTO THE FINAL TABLE
  it_otf_final[] = lt_job_info-otfdata[].

* CONVERTING OTF DATA INTO PDF DATA
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
    IMPORTING
      bin_filesize          = gv_bin_filesize
    TABLES
      otf                   = it_otf_final
      lines                 = it_pdfdata[]
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      err_bad_otf           = 4
      OTHERS                = 5.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " F_CONVERT_PDF
*&---------------------------------------------------------------------*
*&      Form  F_EMAIL_BODY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_email_body .

  DATA: lv_title TYPE ssfcompop-tdtitle.

* To send data as email attachment, we need to have a table of SOLISTI1.
* This table contains line size of 255 characters. Below function module
* does the trick of changing the table from X character sized lines into
* any given Y character sized lines.

  CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    EXPORTING
      line_width_dst              = '255'
    TABLES
      content_in                  = it_pdfdata[]
      content_out                 = it_pdf[]
    EXCEPTIONS
      err_line_width_src_too_long = 1
      err_line_width_dst_too_long = 2
      err_conv_failed             = 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.

* SUBJECT OF THE MAIL.
  CONCATENATE lt_composer_param-tdtitle' : ' lt_bil_invoice-hd_gen-bil_number
         INTO lv_title SEPARATED BY space.

  wa_document_data-obj_name = 'MAIL_TO_HEAD'.
  wa_document_data-obj_descr = lv_title.

* BODY OF THE MAIL
  wa_body_msg = 'Hi,'.
  APPEND wa_body_msg TO it_body_msg.
  CLEAR wa_body_msg.

  wa_body_msg = 'This is test body email for Billing Document creation.'.
  APPEND wa_body_msg TO it_body_msg.
  CLEAR wa_body_msg.
ENDFORM.                    " F_EMAIL_BODY
*&---------------------------------------------------------------------*
*&      Form  F_PACKING_LIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_packing_list .

* WRITE PACKING LIST FOR BODY
  DESCRIBE TABLE it_body_msg LINES gv_tab_lines.
  wa_packing_list-head_start = 1.
  wa_packing_list-head_num = 0.
  wa_packing_list-body_start = 1.
  wa_packing_list-body_num = gv_tab_lines.
  wa_packing_list-doc_type = 'RAW'.
  APPEND wa_packing_list TO it_packing_list.
  CLEAR wa_packing_list.

* WRITE PACKING LIST FOR ATTACHMENT
  wa_packing_list-transf_bin = 'X'.
  wa_packing_list-head_start = 1.
  wa_packing_list-head_num = 1.
  wa_packing_list-body_start = 1.

  DESCRIBE TABLE it_pdf LINES wa_packing_list-body_num.
  wa_packing_list-doc_type = 'PDF'.
*    w_packing_list-obj_descr = 'PDF Attachment'.
  wa_packing_list-obj_descr = lt_composer_param-tdtitle.
  wa_packing_list-obj_name = 'PDF_ATTACHMENT'.
  wa_packing_list-doc_size = wa_packing_list-body_num * 255.
  APPEND wa_packing_list TO it_packing_list.
  CLEAR wa_packing_list.

* FILL THE DOCUMENT DATA &GET SIZE OF ATTACHMENT
  wa_document_data-obj_langu = sy-langu.
  wa_document_data-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( wa_attachment ).

ENDFORM.                    " F_PACKING_LIST



Friday, August 3, 2012

Selection, with validation of the fields

DATA: ls_where(72) TYPE c,

lt_where LIKE TABLE OF ls_where,

* create where condition
  IF NOT stru_node_vbak-vbeln EQ ''.
    CONCATENATE 'VBELN = ''' stru_node_vbak-vbeln '''' INTO ls_where.
    APPEND ls_where TO lt_where.
  ENDIF.


IF NOT stru_node_vbak-erdat EQ '00000000'.
    CONCATENATE 'ERDAT = ''' stru_node_vbak-erdat '''' INTO ls_where.
    IF stru_node_vbak-vbeln NE ''.
      CONCATENATE 'AND' ls_where INTO ls_where SEPARATED BY space.
    ENDIF.
    APPEND ls_where TO lt_where.
ENDIF.

SELECT VBELN ERDAT ERZET ERNAM ANGDT BNDDT AUDAT VBTYP TRVOG AUART
         AUGRU GWLDT SUBMI LIFSK FAKSK NETWR WAERK VKORG VTWEG SPART
         VKGRP VKBUR GSBER GSKST GUEBG GUEEN KNUMV
  FROM vbak INTO TABLE lt_vbak WHERE (lt_where).

Thursday, June 16, 2011

Concatenate blank space

I had a setback in concatenating blank spaces in between variables/fields.
My case scenario. I have 10 fields. Need to concatenate them all. However, lets say for field6, 7, and 8, i would like them to have spaces in between when concatenated. For the rest of the fields, no space is needed when concatenated together.

How i solved:
Solution found here: http://forums.sdn.sap.com/thread.jspa?threadID=1323937
I declared a variable eg: v_space type C value ' '.
The space in between the apostrophes is done via pressing buttons ALT 2 5 5...and magically creates a blank space in between the apostrophes.

Friday, August 13, 2010

IF NOT EQUAL PROBLEM

I made a stupid careless mistake in coding IF statement with 2 NOT EQUAL checks.

The wrong coding.

        if tt_mbewa2-lfgja NE v_ersda(4) AND
           tt_mbewa2-lfmon NE v_ersda+4(2).
          DELETE tt_mbewa2.
        endif.



Instead of using AND, i should user OR



Correct Coding


        if tt_mbewa2-lfgja NE v_ersda(4) OR
           tt_mbewa2-lfmon NE v_ersda+4(2).
          DELETE tt_mbewa2.
        endif.

UC_OBJECTS_NOT_NUMLIKE Error when DELETE

I have encountered this problem when trying to delete.

Ive found the solution on the net.
Here you go:
      loop at tt_mbewa2.
        if tt_mbewa2-lfgja NE v_ersda(4) OR
           tt_mbewa2-lfmon NE v_ersda+4(2).
          DELETE tt_mbewa2.
        endif.
      endloop.