Friday, August 28, 2020

Batch Validation COR1 in PP Module In SAP

Enhancement COR1 for Batch Validation In SAP  PP Module.



Include Name: ZXCO1U06 COR1 for Batch Validation.


IF sy-tcode =  'COR1' OR sy-tcode =  'COR2' ).
  IF header_imp-auart 'ZA02' OR header_imp-auart 'ZU02'
  OR header_imp-auart 'ZA01' OR header_imp-auart 'ZA03'
  OR header_imp-auart 'ZU01' OR header_imp-auart 'ZU10'.
*************************
    FIELD-SYMBOLS <fs_afpo1> TYPE any.
*************************
    DATA ls_afpo1 TYPE afpod.
    TYPESBEGIN OF ty_mch11,
              matnr TYPE matnr,     "Material
              charg TYPE charg_d,   "Batch No
              lvorm TYPE lvoc1,
              ersda TYPE ersda,     "Date
              END OF ty_mch11.
    TYPESBEGIN OF ty_batch11,
            charg TYPE charg_d,
            atwtb TYPE ersda,
            END OF ty_batch11.
    DATA wa_mch11 TYPE ty_mch11,
           wa_mch21 TYPE ty_mch11,
           i_mch11 TYPE STANDARD TABLE OF ty_mch11.
    DATAv_mcha1 TYPE mcha,
          class1 TYPE klah-class,
          w_batch2 TYPE clbatch,
          i_batch2 TYPE STANDARD TABLE OF clbatch,
          w_batch11 TYPE ty_batch11,
          i_batch11 TYPE STANDARD TABLE OF ty_batch11.
    DATAv_date1 TYPE sy-datum.
    DATArec1 TYPE i.
    DATAv_count1 TYPE i.   " counter for loop
    ASSIGN ('(SAPLCOKO)AFPOD'TO <fs_afpo1>.
    ls_afpo1 <fs_afpo1>.
    SELECT matnr
           charg
           lvorm
           ersda
           
           charg
           lvorm
           ersda
           FROM mch1 INTO TABLE i_mch11
           
           WHERE matnr header_imp-plnbez.
    DATA:lv_lvorm1 TYPE lvoc1.
    CLEAR:lv_lvorm1.
    SELECT SINGLE matnr
                  charg
                  lvorm
                  ersda
                  
                  charg
                  lvorm
                  ersda
                  FROM mch1 INTO wa_mch21
                  
                  WHERE matnr header_imp-plnbez
                    
                    AND charg ls_afpo1-charg.
    IF wa_mch21-lvorm 'X'.
      MESSAGE  e005(zbtch_msgWITH ls_afpo1-charg header_imp-plnbez.
    ENDIF.
  ENDIF.
ENDIF.

Friday, July 24, 2020

TOC Creation Step by Step in SAP

TOC Creation Step by Step in SAP ABAP.


Step 1 :

First Goto T-Code  SE09 – Create Request   – Select Transport of Copies



 


 


 

Step 2 : Put your Description  for TOC ,give the target system as RB2.100 / PS2.100 – after that click on Save button.


Step 3 : Right click on TOC created above , and click on “Include Objects”


Step 4 : Enter the “Task Number( remember it’s the task number that you need and not the main request ) from which you want to create TOC so that objects from this task are included in TOC



Step 5 :Right click on TOC and say “Release Directly “




Step 6 : Click Continue if any pop up appears and on the next screen click “Refresh” till release is complete . Once Release is complete then only the TOC would appear in RB2 queue ( in STMS)

 


Step 8 :Double click on “ RB2” for selecting  RB2 queue

 


Step 9 : Click on “Refresh” . Once Refresh is done , our TOC would appear in RB2 Queue




 

Step 10 :Click on TOC Request and then click on button “Adjust Import Queue” from Menu bar



Step 12 :Click on the TOC and click on “ Import Directly” button from menu bar


Step 14 :Click on Refresh till “truck” icon before TOC disappears and a “Tick” mark appears indicating transport successful


Thursday, July 23, 2020

MB_MIGO_BADI BADI USED TO POSTING DATA VALIDATION FOR MIGO

MB_MIGO_BADI BADI



method IF_EX_MB_MIGO_BADI~POST_DOCUMENT.

  BREAK-POINT.

  IF is_mkpf-budat < is_mkpf-BLDAT.

    sy-ucomm 'ENT1'.

    MESSAGE 'Posting Date Should Not Less Than Document Date'  TYPE 'E' .

    SET SCREEN syst-dynnr.

    LEAVE SCREEN.

  ENDIF.

endmethod.

POPUP Confirm Message for SAP ABAP.

SAP ABAP Program for POPUP Confirm Message.


Data : w_answer(01) type c.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

titlebar = text-006

text_question = text-001

text_button_1 = text-002

text_button_2 = text-003

display_cancel_button = ' '

IMPORTING

answer = w_answer.

Note: text-001 - Are you sure do you want to continue?

text-002 - Yes

text-003 - No

text-006 - Delete ( Information that you would like to give for the titlebar )

Send Mail Excel attachment program in SAP ABAP

Send Mail Excel attachment program in SAP ABAP.




DATA: lt_mailrecipients  TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE,

      lt_mailtxt         TYPE STANDARD TABLE OF soli      WITH HEADER LINE,

      lt_attachment      TYPE STANDARD TABLE OF solisti1  WITH HEADER LINE,

      lt_mailsubject     TYPE sodocchgi1,

      lt_packing_list    TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,

      gv_cnt             TYPE i.


Add Recipients


lt_mailrecipients-rec_type  = 'U'.

lt_mailrecipients-com_type  = 'INT'.

lt_mailrecipients-RECEIVER  = 'someone@erpdb.info'.

APPEND lt_mailrecipients .

CLEAR lt_mailrecipients .


Put in the Mail Contents


lt_mailtxt = 'Hi How are you'.      APPEND lt_mailtxt. CLEAR lt_mailtxt.

lt_mailtxt = 'Here is a test mail'. APPEND lt_mailtxt. CLEAR lt_mailtxt.

lt_mailtxt = 'Thanks'.              APPEND lt_mailtxt. CLEAR lt_mailtxt.


Create the attachment


  DATA: BEGIN OF lt_po_data_cons OCCURS 0,

         ebeln LIKE ekpo-ebeln,

         ebelp LIKE ekpo-ebelp,

        END OF lt_po_data_cons.


  SELECT ebeln ebelp INTO TABLE lt_po_data_cons

  UP TO 10 ROWS

  FROM ekpo. 


  CLASS cl_abap_char_utilities DEFINITION LOAD.

  CONCATENATE 'PO' 'PO Line'

              INTO lt_attachment SEPARATED BY

              cl_abap_char_utilities=&GT;horizontal_tab.

  APPEND lt_attachment. CLEAR lt_attachment.


  LOOP AT lt_po_data_cons.

  CONCATENATE lt_po_data_cons-ebeln lt_po_data_cons-ebelp

              INTO lt_attachment SEPARATED BY

              cl_abap_char_utilities=&GT;horizontal_tab.


  CONCATENATE cl_abap_char_utilities=&GT;newline lt_attachment

              INTO lt_attachment.


  APPEND lt_attachment. CLEAR lt_attachment.

 ENDLOOP.

Pack the mail contents and attachment

 lt_packing_list-transf_bin  = SPACE.

  lt_packing_list-head_start  = 1.

  lt_packing_list-head_num    = 0.

  lt_packing_list-body_start  = 1.

  lt_packing_list-body_num    = LINES( lt_mailtxt ).

  lt_packing_list-doc_type    = 'RAW'.

  APPEND lt_packing_list. CLEAR lt_packing_list.


  lt_packing_list-transf_bin  = 'X'.

  lt_packing_list-head_start  = 1.

  lt_packing_list-head_num    = 1.

  lt_packing_list-body_start  = 1.

  lt_packing_list-body_num    = LINES( lt_attachment ).

  lt_packing_list-doc_type    = 'XLS'. " You can give RAW incase if you want just a txt file.

  lt_packing_list-obj_name    = 'data.xls'.

  lt_packing_list-obj_descr   = 'data.xls'.

  lt_packing_list-doc_size    = lt_packing_list-body_num * 255.

  APPEND lt_packing_list. CLEAR lt_packing_list.


  lt_mailsubject-obj_name     = 'MAILATTCH'.

  lt_mailsubject-obj_langu    = sy-langu.

  lt_mailsubject-obj_descr    = 'You have got mail'.

  lt_mailsubject-sensitivty   = 'F'.

  gv_cnt = LINES( lt_attachment ).

  lt_mailsubject-doc_size     = ( gv_cnt - 1 ) * 255 + STRLEN(

  lt_attachment ).

Finally, send the mail out.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

      document_data              = lt_mailsubject

    TABLES

      packing_list               = lt_packing_list

      contents_bin               = lt_attachment

      contents_txt               = lt_mailtxt

      receivers                  = lt_mailrecipients

    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 EQ 0.

    COMMIT WORK.

    SUBMIT rsconn01 WITH MODE = 'INT' AND RETURN.

  ENDIF.

Read Long Text In SAP ABAP Programming Langauge

Read Long (READ_TEXT)Text In SAP ABAP Programming Langaug.

READ_TEXT function module call for long text.

**********************************
DATA:lv_output_text TYPE char222.
DATAtname TYPE thead-tdname."TYPE thead-tdname.
*----------------------------------------------------------------------*
* Data Declarations.
* Internal Tables.
  DATA:
    lt_lines TYPE STANDARD TABLE OF tline,
    pc_output_text(222TYPE c.

* Field Symbols.
  FIELD-SYMBOLS:
    <fs_lines> TYPE tline.

*Local Constants:
 CONSTANTS:
   lc_id                TYPE thead-tdid       VALUE '0001',
   lc_object            TYPE thead-tdobject   VALUE 'DOC_ITEM'.


  CONCATENATE gs_item-rbukrs gs_item-belnr gs_item-gjahr gs_item-buzei INTO tname.

                  CALL FUNCTION 'READ_TEXT'
                    EXPORTING
                      client                        sy-mandt
                      id                            lc_id
                      language                      sy-langu
                      name                          tname
                      object                        lc_object
*                     ARCHIVE_HANDLE                = 0
*                     LOCAL_CAT                     = ' '
*                   IMPORTING
*                     HEADER                        =
*                     OLD_LINE_COUNTER              =
                    TABLES
                      lines                         lt_lines
                   EXCEPTIONS
                     id                            1
                     language                      2
                     name                          3
                     not_found                     4
                     object                        5
                     reference_check               6
                     wrong_access_to_archive       7
                     OTHERS                        8
                            .

  IF sy-subrc EQ 0.
*  Fetch the text from the FM table.
    READ TABLE lt_lines
    ASSIGNING <fs_lines>
    INDEX 1.
    IF sy-subrc EQ 0.
      pc_output_text <fs_lines>-tdline.
    ENDIF.
  ENDIF.
ENDIF.