Showing posts with label ABAP. Show all posts
Showing posts with label ABAP. Show all posts

Monday, July 11, 2011

SAP APO enhancement for AFS


Recently I had to work on a project were the customer was planning to implement SAP AFS and SAP APO to handle their business requirements. The development challenge on this requirement was to maintain 2 different locations for each plant created in AFS side. This was required in order to plan for wholesaled and retail requirements of the business. This was maintained in AFS side on the category structure in for a given material.
I have mentioned the exits used I used during this modification. Hope this will be helpful for someone who need to modify data which is gets transferred to APO.

SAP standard industrial enhancement BADI:
CIF_EXT_IS_INTERNAL
AFS implementation name: /AFS/NDIF_APO

User exits for each area

1)      Enhancement for plant data transfer :
User exits: EXIT_SAPLCLOC_001
Enhancement: CIFLOC01 Enhancement for Transferring Customer-Specific Loc. Fields

2)      Enhancement for material data transfer :
User exits: EXIT_SAPLCMAT_001
Enhancement: CIFMAT01 Enhancement for Transferring Customer-Specific Matl Fields

3)      Enhancement for PO/POC/PR  data transfer :
User exits: EXIT_SAPLMEAP_001
Enhancement: CIFPUR01 Enhancement for Transferring Customer-Specific PO Fields

4)      Enhancement for SO data transfer:
User exit: EXIT_SAPLCSLS_002
Enhancement: CIFSLS03 Influencing of Sales Order Data Prior to Dispatch

5)      Enhancement for Source of supply or Purchase info record  data transfer:
User exit: EXIT_SAPLCSRS_003
Enhancement: CIFSRC01 Enhancement for Transferring Customer-Specific SS Fields

6)      Enhancement for stock data transfer:
User exit: EXIT_SAPLCSTK_001
Enhancement: CIFSTK01 Enhancement for Transferring Customer-Specific Stock Fields

7)      Enhancement for Batches transfer :
User exits: EXIT_SAPLCCHG_001
Enhancement: CIFBTC01 Enhancement for Transferring Customer-Specific Batch Fields

Saturday, October 9, 2010

The final touch (add a htmp page on SAP screen)

It's a known fact that however complex your program is when it come to the user. The look and feel of the output is what matters most. This is blog post is about a simple trick that we can do to make the look and feel better.
Have you ever wondered that when you develop a tool to your customer on a area ( eg: Order Automation tool ). That its better if you can get them a initial screen with some fancy graphics on it where you will be able to give multiple links to different Transactions.
If yes this is one approach that I figured out
Adding a HTML page on SAP

Ok now that I have given a brief idea on what I am talking about. I’ll just walk you through example where a html page is added to initial transaction of a automation tool
Below Is the final output what we are going to get (I have added some SAP images since it is a example case )


 Ok now some basic steps we need to create the above
1)      The html page uploaded to your SAP system (tcode : SMW0)
2)      The images you required to be uploaded in the SAP system )(tcode : SMW0)
Please note that to trigger the event you need something similar to the below part to be added to the html code
<td><a href=SAPEVENT:ZORD_SPLIT ><strong><i>Order Spliti>strong>a>td>

The code to call the relevant transaction is as below
class cl_myevent_handler definition.

  
public section.
    
methods: on_sapevent
               
for event sapevent of cl_gui_html_viewer
                 
importing action frame getdata postdata query_table.

endclass.

data: evt_receiver type ref to cl_myevent_handler.

* CLASS CL_GUI_CFW DEFINITION LOAD.


class cl_myevent_handler implementation.

  
method on_sapevent.
    
case action.
      
WHEN 'ZORD'.
        
CALL TRANSACTION 'ZORD'.
      
WHEN 'ZORD_SPLIT'.
        
CALL TRANSACTION 'ZORD_SPLIT'.
    
endcase.


  
endmethod.
In this test case I have created a container as HTML_CONTROL

if html_control is initial.

    prog_repid = sy-repid.

    
create object my_container
        
exporting
            container_name = 
'HTML_CONTROL'.

    
create object html_control
         
exporting
              parent    = my_container.
    
if sy-subrc ne 0.
*      do nothing.
    
endif.

* register event
    myevent-eventid = html_control->m_id_sapevent.
    myevent-appl_event = 
'x'.
    
append myevent to myevent_tab.
    
call method html_control->set_registered_events
        
exporting
           
events = myevent_tab.

    
create object evt_receiver.

    
set handler evt_receiver->on_sapevent
                
for html_control.

    
perform load_graphics.
    
perform load_home_page.

  
endif.

You can call load graphics and map you html image with your image uploaded to SAP
   call method html_control->load_mime_object
     
exporting
          object_id  = 
'ZSAP_IMG'
          object_url = 
‘image.jpeg’
     
exceptions
          
others     = 1.
The once load call your html page as below
  call method html_control->load_html_document
       
exporting
            document_id  = 
'ZTEST_PAGE_6'
       
importing
            assigned_url = doc_url
       
exceptions
            
others       = 1.

  
if sy-subrc eq 0.
    
call method html_control->show_url
         
exporting
              url = doc_url.
  
endif.
If you call your screen now you should see the html page with all the images and links .
For a abaper this is not a big piece of work but adding something like this will always give you some extra hip

Tuesday, March 9, 2010

selection option recommended sign

 

most of the time when we develop a report program or a selection screen. We have to remove the standard validation which comes when we define a selection option as mandatory and add a custom validation. In such cases we are unable to display the selection option as a mandatory sign. To do this we can make the input field recommended which will give the sign. bellow is the code how to do it.



AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

   IF screen-name EQ 'S_WERKS-LOW'.
     screen-required = 2. "2 is recommended
   ENDIF.

  MODIFY SCREEN.

ENDLOOP. 

Monday, March 8, 2010

selection screen with tabs

This post is about selection screen with tabs. Selection screen with tabs are not that hard to implement on ABAP and I am sure if you search online you will always get the code for it.... but just to start things ill just give the code no a basic selection screen with tabs...

SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
           
SELECT-OPTIONS: s_ebeln FOR zconf_stage-ebeln,
                s_ebelp FOR zconf_stage-ebelp,
                s_bsart FOR ekko-bsart,
                s_werks FOR ekpo-werks,
                s_matnr FOR ekpo-matnr,
                s_lifnr FOR ekko-lifnr,
                s_ekgrp FOR ekko-ekgrp,
                s_budat FOR zconf_stage-budat,
                s_kunnr FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN END OF SCREEN 101.


SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN .

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_ebeln1 FOR zconf_stage-ebeln,
                s_bsart1 FOR ekko-bsart,
                s_werks1 FOR ekpo-werks ,
                s_matnr1 FOR ekpo-matnr,
                s_lifnr1 FOR ekko-lifnr,
                s_ekgrp1 FOR ekko-ekgrp,
                s_budat1 FOR zconf_stage-budat,
                s_kunnr1 FOR vbpa-kunnr.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN END OF SCREEN 102.

SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 24 LINES,
TAB (30) button1 USER-COMMAND on,
TAB (30) button2 USER-COMMAND auto,
END OF BLOCK mytab.


INITIALIZATION.
  button1 = text-011.
  button2 = text-012.

  mytab-prog = sy-repid.
  mytab-dynnr = 101.
  mytab-activetab = 'BUTTON1'.



AT SELECTION-SCREEN .

  IF sy-batch = 'X'.
    mytab-dynnr = 102.
    mytab-activetab = 'BUTTON2'.
    sy-ucomm = 'AUTO'.
  ENDIF.

  CASE sy-dynnr.

    WHEN 1000.
      CASE sy-ucomm.
        WHEN 'ON'.
          mytab-dynnr = 101.
          mytab-activetab = 'BUTTON1'.
        WHEN 'AUTO'.
          mytab-dynnr = 102.
          mytab-activetab = 'BUTTON2'.
      endcase.

    WHEN 0101.
      mytab-dynnr = 101.
      mytab-activetab = 'BUTTON1'.
    WHEN 'ONLI'.
          PERFORM screen_validation101.
      ENDCASE.

    WHEN 0102.
      mytab-dynnr = 102.
      mytab-activetab = 'BUTTON2'.
      case sy-ucomm.
    WHEN 'ONLI'.
          PERFORM screen_validation102.
      ENDCASE.
  ENDCASE.

START-OF-SELECTION.

  CASE mytab-activetab.
    WHEN 'BUTTON1'."online mode
   
    WHEN 'BUTTON2'." when automatic
    
  ENDCASE.

now the above code is to a selection screen with tabs that you code using a report program.( this code cannot be used in module pool program )

When a customer request to a selection screen with tabs there can be 2 reasons.

1) To group a selection on one out put ( I mean the final out-put is one but selection screen can be with tabs to make things clear for e.g on SD related report the tabs can be Material selection , SO selection like wise )

2) The user requires different kind of out comes with different tabs... for e.g tab no1 to work during online operations and tab no 2 to work on background operations.

The above requirement 1 which will be totally fine with the code given on top. But the requirement 2 will be a issue when it comes to the above code. As most of the developers know on a selection screen we will always have mandatory fields. when switching between tabs the selection screen first calls the validation and then it calls the normal screen code ( as you know the validation is automatic if me make a selection option mandatory and we have no say on it ).
  So in case if the user wants the functionality of the tab 2 he first has to fill all the mandatory fields on tab 1 so that the error wont occur. This was a error I had to face during my development for this there are 2 way outs

1) do the validation by your self ( draw back : you wont get the mandatory sign on the selection screen )
2) write a selection screen with tabs ( draw back : the user wont be able to save variants or this part has to be coded which will be a messy job ) 

for the 2nd option on above to make sure the tab switching with happen without first validating you have to do the codding as follows

PROCESS BEFORE OUTPUT.
  MODULE STATUS_0100.
  MODULE set_tabs.

  call SUBSCREEN SUB INCLUDING sy-repid gv_dynnr.
*
PROCESS AFTER INPUT.

  MODULE exit_comm.
  MODULE switch_tab.
  CALL SUBSCREEN SUB.
  MODULE screen_comm.

  MODULE USER_COMMAND_0100.


before call sub screen you have to call a module switch tabs.

on my case my customer wanted the variants to be there. Therefore they agreed to the validation by code where the mandatory sign is not displayed.

Wednesday, September 16, 2009

when and where we can use parallel cursor


Loop AT i_primary into wa_primary.
Loop AT i_secondary into wa_secondary from lv_index.
If ( wa_primary-field1 NE wa_secondary-field1 ) or
( wa_primary-field2 NE wa_secondary-field2 ).
Lv_index = sy-tabix.
Endif.
“ your code comes here “
Endloop.
Endloop.
To use this following should be true
1)      Both tables should be sorted with the same key ( in the above case field1 and field2 )
2)      The mapping between primary to secondary tables should be
a.       one to many ( for one record in primary there are multiple records in secondary )
b.      one to one (for one record in primary there is only one in secondary )
Please note that other than the above 2 other 2 scenarios (many to many & many to one) will not work with the above logic and make sure you don’t use in such case.
3)      The secondary table should not contain a record which does not map to the primary table ( this will not happen if the secondary is fetched using for all entries from primary )
4)      Please make sure you do not delete any record from primary before using the logic which will make the point 3 false  
5)      If you were to use a 'AND' in where statement of the inner loop you should use or in the inner loop if condition in the above logic. 
 

Friday, September 11, 2009

Copy to Clipborad SAP

copy to clipborad

Bellow code is how to copy data to clipboard. This feature helps you when there is a BDC recording and you want to add selection extended options

    DATA: v_rc TYPE I,
       it_data TYPE STANDARD TABLE OF CHAR128,
       wa_data TYPE char128.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_EXPORT
    IMPORTING DATA = it_data
    CHANGING RC = v_rc      .

Monday, August 31, 2009

How to add a button on selection screen


one small thing I came across on a customer development was to add a button on the selection screen. I have not done such a requirement before for any customer so i didn't any idea on how to do it.

After doing some searching this is what I found out was :).

For a selection screen you can put up to 5 buttons this is a default feature which is available to use if you want.
For that these are the steps you have to do

I have added the button in two ways one is just the button with the text next one button with a icon.

The data declarations for these are.
TABLES: sscrfields.
DATA: functxt TYPE smp_dyntxt.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
TITLE TEXT-001.
SELECT-OPTIONS: p_ktopl FOR t030-ktopl.

SELECTION-SCREEN END OF BLOCK block1.


SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.


functxt-icon_id = ICON_HISTORY.
functxt-quickinfo = 'log'(001).
sscrfields-functxt_01 = functxt.

MOVE 'Maintain Item Cat.' TO sscrfields-functxt_02.






Thursday, July 16, 2009

how to add tooltip to icon


its very easy to add tooltip to icon's

1) have a icon field in output table ( this can be a char field with 25 characters)

2) in case if you cant to add the lock icon for that icon field put
-icon = '@06\QIn process@'.

in this @06@ is the icon when you give the tooltip with '\QXXXtooltipXXX'
insert this part beore last @.

Note: if you want to find the icons check icon table :)

3) field catalog make the icon field 'X'.


there is a SAP example on program: BCALV_DEMO_TOOLTIP



Tuesday, June 23, 2009

How to Debug any screen on SAP

its very simple just put this code on a text file and save it with what even name you want e.g debug

[FUNCTION]
Command=/H
Title=Debugger
Type=SystemCommand



when ever you want to debug you dont have to use /h but just drag and drop this on the SAP screen this enables you to debug on popup screens

Hope this will be useful

nafran

Wednesday, June 10, 2009

how to get the first day and last day SAP

Most of the time when we need the first day and the last day of a given month we always run to get a function. why use a function when its so easy to code it

*get first and last date of month and year
CONCATENATE s_bdatj-low s_mnr-low '01' INTO gv_date1.

gv_month = s_mnr-low .
gv_month = gv_month + 01.

CONCATENATE s_bdatj-low gv_month '01' INTO gv_date2.

gv_date2 = gv_date2 - 1.

Thursday, April 23, 2009

Use of binary search option

When a programmer uses the read command, the table is sequentially searched. This slows down the processing. Instead of this, use the binary search addition. The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.

Not Recommended

Read table int_fligh with key airln = ‘LF’.

Recommended

Read table int_fligh with key airln = ‘LF’ binary search.


source: http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_BinarySearch.asp

Modifying a group of lines of an internal table

Use the variations of the modify command to speed up this kind of processing.

Not recommended

Loop at int_fligh.

If int_fligh-flag is initial.

Int_fligh-flag = ‘X’.

Endif.

Modify int_fligh.

Endloop.

Recommended

Int_fligh-flag = ‘X’.

Modify int_fligh transporting flag where flag is initial.


source: http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_ModifyingGroupOfLines.asp


Wednesday, April 15, 2009

copy ALV layouts from a one program to another

*&---------------------------------------------------------------------*
*& Report  Z_COPY_ALV_VARNTS_PROG_TO_PROG
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  Z_COPY_ALV_VARNTS_PROG_TO_PROG.


* =====================================================================
* Data Declarations Section
* =====================================================================

* ---------------------------------------------------------------------
DATA : BEGIN OF MYLTDX OCCURS 0 .
INCLUDE STRUCTURE LTDX .
DATA : END OF MYLTDX .
* ---------------------------------------------------------------------
DATA : BEGIN OF MYLTDXT OCCURS 0 .
INCLUDE STRUCTURE LTDXT .
DATA : END OF MYLTDXT .
* ---------------------------------------------------------------------
DATA : BEGIN OF MYLTDXD OCCURS 0 .
INCLUDE STRUCTURE LTDXD .
DATA : END OF MYLTDXD .
* ---------------------------------------------------------------------

DATA : MANS(1) TYPE C .

DATA : PROGRAMM LIKE RS38M-PROGRAMM .
DATA : BEGIN OF MDYNPFIELDS OCCURS 1 .
INCLUDE STRUCTURE DYNPREAD .
DATA : END OF MDYNPFIELDS .
CONSTANTS BUTTONSELECTED(1) TYPE C VALUE 'X' .

* =====================================================================
* Macro for Inputing Filenames
* =====================================================================
DEFINE GET_FILENAME .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
* DEF_FILENAME = ' '
DEF_PATH = &1
MASK = ',*.*,*.*.'
MODE = '0'
* TITLE = ' '
IMPORTING
FILENAME = &2
* RC =
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.

END-OF-DEFINITION .

* =====================================================================
* Macro for Downloading to ASCII Files
* =====================================================================
DEFINE DOWNLOAD_TO_ASCII .
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = ' '
FILENAME = &1
FILETYPE = 'DAT'
* MODE = ' '
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = &2
* FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.

END-OF-DEFINITION .

* =====================================================================
* Macro for uploading Data from ASCII files
* =====================================================================
DEFINE UPLOAD_FROM_ASCII .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
* CODEPAGE = ' '
FILENAME = &1
FILETYPE = 'DAT'
* HEADLEN = ' '
* LINE_EXIT = ' '
* TRUNCLEN = ' '
* USER_FORM = ' '
* USER_PROG = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = &2
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
END-OF-DEFINITION .

* =====================================================================
* Selection Screen Default
* =====================================================================
PARAMETERS : P_FROM_P LIKE RS38M-PROGRAMM OBLIGATORY .
PARAMETERS : P_TO_P LIKE RS38M-PROGRAMM OBLIGATORY .
PARAMETERS : P_SAME_S RADIOBUTTON GROUP GRP1 DEFAULT 'X' .
PARAMETERS : P_DOWNLD RADIOBUTTON GROUP GRP1 .
PARAMETERS : P_UPLOAD RADIOBUTTON GROUP GRP1 .
PARAMETERS : P_FILE_x LIKE RLGRAP-FILENAME DEFAULT 'c:\LTDX.txt' .
PARAMETERS : P_FILE_t LIKE RLGRAP-FILENAME DEFAULT 'c:\LTDXT.txt' .
PARAMETERS : P_FILE_d LIKE RLGRAP-FILENAME DEFAULT 'c:\LTDXD.txt' .

* =====================================================================
* At Selection Screen Events
* =====================================================================
AT SELECTION-SCREEN .
PROGRAMM = P_FROM_P .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE_x .
GET_FILENAME 'c:\LTDX.txt' P_FILE_x .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE_t .
GET_FILENAME 'c:\LTDXT.txt' P_FILE_t .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE_d .
GET_FILENAME 'c:\LTDXD.txt' P_FILE_d .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FROM_P .
CLEAR MDYNPFIELDS . REFRESH MDYNPFIELDS .
MDYNPFIELDS-FIELDNAME = 'P_FROM_P' .
APPEND MDYNPFIELDS .
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MDYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11.

READ TABLE MDYNPFIELDS INDEX 1 .
PROGRAMM = MDYNPFIELDS-FIELDVALUE .
CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
EXPORTING
OBJECT_TYPE = 'PROG'
OBJECT_NAME = PROGRAMM
IMPORTING
OBJECT_NAME_SELECTED = PROGRAMM
EXCEPTIONS
CANCEL = 1
WRONG_TYPE = 2
OTHERS = 3.
P_FROM_P = PROGRAMM .

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_TO_P .
CLEAR MDYNPFIELDS . REFRESH MDYNPFIELDS .
MDYNPFIELDS-FIELDNAME = 'P_TO_P' .
APPEND MDYNPFIELDS .
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MDYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11.

READ TABLE MDYNPFIELDS INDEX 1 .
PROGRAMM = MDYNPFIELDS-FIELDVALUE .
CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
EXPORTING
OBJECT_TYPE = 'PROG'
OBJECT_NAME = PROGRAMM
IMPORTING
OBJECT_NAME_SELECTED = PROGRAMM
EXCEPTIONS
CANCEL = 1
WRONG_TYPE = 2
OTHERS = 3.
P_TO_P = PROGRAMM .

* =====================================================================
* Start of Selection
* =====================================================================
START-OF-SELECTION .
CASE BUTTONSELECTED.
WHEN P_SAME_S .
PERFORM COPY_FROM_PROG_TO_PROG .
WHEN P_DOWNLD .
PERFORM VDOWNLOAD .
WHEN P_UPLOAD .
PERFORM VUPLOAD .
ENDCASE .

*&---------------------------------------------------------------------*
*& Form COPY_FROM_PROG_TO_PROG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM COPY_FROM_PROG_TO_PROG.

CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
TEXTLINE1 = 'Are you sure you want to copy Variants ? '
* TEXTLINE2 = ' '
TITEL = 'Confirmation '
* START_COLUMN = 25
* START_ROW = 6
* CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = MANS
EXCEPTIONS
OTHERS = 1.

IF MANS = 'J' .
* ---------------------------------------------------------------------
REFRESH MYLTDX . CLEAR MYLTDX .
SELECT * FROM LTDX INTO TABLE MYLTDX
WHERE REPORT = P_FROM_P.
LOOP AT MYLTDX .
MYLTDX-REPORT = P_TO_P .
MODIFY MYLTDX .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDX WHERE REPORT = P_TO_P .
INSERT LTDX FROM TABLE MYLTDX .
ENDIF .
* ---------------------------------------------------------------------
REFRESH MYLTDXT . CLEAR MYLTDXT .
SELECT * FROM LTDXT INTO TABLE MYLTDXT
WHERE REPORT = P_FROM_P.
LOOP AT MYLTDXT .
MYLTDXT-REPORT = P_TO_P .
MODIFY MYLTDXT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDXT WHERE REPORT = P_TO_P .
INSERT LTDXT FROM TABLE MYLTDXT .
ENDIF .
* ---------------------------------------------------------------------
REFRESH MYLTDXT . CLEAR MYLTDXT .
SELECT * FROM LTDXT INTO TABLE MYLTDXT
WHERE REPORT = P_FROM_P.
LOOP AT MYLTDXT .
MYLTDXT-REPORT = P_TO_P .
MODIFY MYLTDXT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDXT WHERE REPORT = P_TO_P .
INSERT LTDXT FROM TABLE MYLTDXT .
ENDIF .
* ---------------------------------------------------------------------
ENDIF .

ENDFORM. " COPY_FROM_PROG_TO_PROG

*&---------------------------------------------------------------------*
*& Form VDOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VDOWNLOAD.
REFRESH MYLTDX . CLEAR MYLTDX .
SELECT * FROM LTDX INTO TABLE MYLTDX
WHERE REPORT = P_FROM_p.
DOWNLOAD_TO_ASCII P_FILE_x MYLTDX .

* ---------------------------------------------------------------------
REFRESH MYLTDXT . CLEAR MYLTDXT .
SELECT * FROM LTDXT INTO TABLE MYLTDXT
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE_t MYLTDXT .

* ---------------------------------------------------------------------
REFRESH MYLTDXT . CLEAR MYLTDXT .
SELECT * FROM LTDXD INTO TABLE MYLTDXT
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE_d MYLTDXT .

* ---------------------------------------------------------------------

ENDFORM. " VDOWNLOAD

*&---------------------------------------------------------------------*
*& Form VUPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM VUPLOAD.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
TEXTLINE1 =
'Are you sure you want to upload Variants ? '
* TEXTLINE2 = ' '
TITEL = 'Confirmation '
* START_COLUMN = 25
* START_ROW = 6
* CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = MANS
EXCEPTIONS
OTHERS = 1.

IF MANS = 'J' .
* ---------------------------------------------------------------------
REFRESH MYLTDX . CLEAR MYLTDX .
UPLOAD_FROM_ASCII P_FILE_x MYLTDX .
LOOP AT MYLTDX .
MYLTDX-REPORT = P_TO_P .
MODIFY MYLTDX .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDX WHERE REPORT = P_TO_P .
INSERT LTDX FROM TABLE MYLTDX .
ENDIF .
* ---------------------------------------------------------------------
REFRESH MYLTDXT . CLEAR MYLTDXT .
UPLOAD_FROM_ASCII P_FILE_t MYLTDXT .
LOOP AT MYLTDXT .
MYLTDXT-REPORT = P_TO_P .
MODIFY MYLTDXT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDXT WHERE REPORT = P_TO_P .
INSERT LTDXT FROM TABLE MYLTDXT .
ENDIF .
* ---------------------------------------------------------------------
REFRESH MYLTDXD . CLEAR MYLTDXD .
UPLOAD_FROM_ASCII P_FILE_d MYLTDXT .
LOOP AT MYLTDXT .
MYLTDXT-REPORT = P_TO_P .
MODIFY MYLTDXT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM LTDXT WHERE REPORT = P_TO_P .
INSERT LTDXT FROM TABLE MYLTDXT .
ENDIF .
* ---------------------------------------------------------------------
ENDIF .

ENDFORM. " VUPLOAD
Google